Skip to content

Instantly share code, notes, and snippets.

@Nilanth

Nilanth/.jsx Secret

Created July 10, 2021 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nilanth/77821579f54bc9e7d0c4454410826084 to your computer and use it in GitHub Desktop.
Save Nilanth/77821579f54bc9e7d0c4454410826084 to your computer and use it in GitHub Desktop.
const [progress, setProgress] = useState(0);
//Logic to show upload progress
const config = {
onUploadProgress: progressEvent => {
const percentCompleted = Math.round( (progressEvent.loaded * 100) / progressEvent.total );
setProgress(percentCompleted);
}
};
try {
const updatedData = axios.put('/upload/server', data, config);
return updatedData.response.data;
} cactch(error) {
//log error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment