Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

axios upload progress react

function uploadImage(file, updateProgress) {
  return axios.post('/api/media_objects', file, {
    onUploadProgress: progressEvent => {
      let percentComplete = progressEvent.loaded / progressEvent.total
      percentComplete = parseInt(percentComplete * 100);
      console.log(percentComplete);
      updateProgress(percentComplete);
    }
  }).then(response => response.data.id);
}
 
PREVIOUS NEXT
Tagged: #axios #upload #progress #react
ADD COMMENT
Topic
Name
3+7 =