Skip to content

Commit

Permalink
fix for progress
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-laplante committed May 11, 2024
1 parent 61d8846 commit 39659ff
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/FetchWithProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ const FetchWithProgress: React.FC<FetchProgressProps> = (props: FetchProgressPro

const fetchData = () => {
async function work() {
setLoading(true);
const ret = await axios.get(props.url, {
onDownloadProgress: progressEvent => {
const percentage = Math.round(progressEvent.loaded * 100) / progressEvent.total;
console.log(percentage);
setProgress(percentage);
},
responseType: "arraybuffer"
});
setLoading(false);

props.setData(ret.data);
}
Expand Down

0 comments on commit 39659ff

Please sign in to comment.