Source code: openjavascript.info/2022/12/21/download-progress-with-javascripts-fetch-function/ For upload progress, this isn't yet possible with fetch, but you can get it with: XMLHttpRequest (native solution): ruclips.net/video/9biknk9SecY/видео.html Axios: ruclips.net/video/nC3ntJUQrAM/видео.html
Yeah, this is a bit more complicated than with Axios. But it doesn't get any easier with Fetch and at least you get to become more familiar with streams :)
Question, so this is reading back the content that we are receiving from the url. What if we want to read the content being sent to a url? For instance I am sending files to a server, which is then doing some work to create thumbnails of the images and save them to an S3 bucket on AWS. Is it possible to read that progress in the body of the fetch? Or shall I stick to an XMLHttpRequest?
Hi Jacob great question. It's something I've often wondered about and looked into numerous times. Unfortunately my understanding is that at the current time it isn't possible to track upload progress with fetch. The options (for now) are basically XMLHttpRequest or using a library like Axios that uses it under the hood. I do plan on a fetch upload progress tutorial as soon as it become available. I'll try to remember to post here again when that day arrives.
@@OpenJavaScript Even though I am yet to implement it or try it... I saw somewhere on mozilla, when I was learning about streams, that you can create a Request with some ReadableStream, which is then use to track the data sent...
Already have a tutorial on download progress with a bar using Axios: ruclips.net/video/QabJ7e7ku58/видео.html For async/await, you may want to check out my more general tutorial on that: ruclips.net/video/7l2-ds_U2Lc/видео.html Or, maybe even this one on using Fetch with async/await since the syntax is so similar so can be easily adapted for Axios: ruclips.net/video/8JcCdp2Y4Q4/видео.html
Unfortunately, at the current time Fetch does not support upload progress. Until, then you're better off using ajax for a native solution (ruclips.net/video/9biknk9SecY/видео.html) or axios (ruclips.net/video/nC3ntJUQrAM/видео.html)
Source code: openjavascript.info/2022/12/21/download-progress-with-javascripts-fetch-function/
For upload progress, this isn't yet possible with fetch, but you can get it with:
XMLHttpRequest (native solution): ruclips.net/video/9biknk9SecY/видео.html
Axios: ruclips.net/video/nC3ntJUQrAM/видео.html
Thank you very much! Not many tutorials about this on the web using real data.
Wow. Maybe i can understand all these JS code until next year haha
Thanks, bro!
Abraço!
Yeah, this is a bit more complicated than with Axios. But it doesn't get any easier with Fetch and at least you get to become more familiar with streams :)
Wow, very useful, understandable and easy.!!!
You're super!
Thank you for sharing.
You're welcome, glad you found it useful!
This could be done when obtaining data from the DB, monitoring approximately how long the request will take or it only works with files.
Bro, why use the spread operator on the response => header?
Thanks man
wowww thank you so much!
You're welcome. The solution is a bit long-winded but works for now until there is some sort of native onProgress function added to Fetch.
that's why i'm grateful for axios
Very good content
Thanks David!
Question, so this is reading back the content that we are receiving from the url. What if we want to read the content being sent to a url? For instance I am sending files to a server, which is then doing some work to create thumbnails of the images and save them to an S3 bucket on AWS. Is it possible to read that progress in the body of the fetch? Or shall I stick to an XMLHttpRequest?
Hi Jacob great question. It's something I've often wondered about and looked into numerous times.
Unfortunately my understanding is that at the current time it isn't possible to track upload progress with fetch.
The options (for now) are basically XMLHttpRequest or using a library like Axios that uses it under the hood.
I do plan on a fetch upload progress tutorial as soon as it become available. I'll try to remember to post here again when that day arrives.
@@OpenJavaScript Even though I am yet to implement it or try it... I saw somewhere on mozilla, when I was learning about streams, that you can create a Request with some ReadableStream, which is then use to track the data sent...
axios first with async await
Already have a tutorial on download progress with a bar using Axios: ruclips.net/video/QabJ7e7ku58/видео.html
For async/await, you may want to check out my more general tutorial on that: ruclips.net/video/7l2-ds_U2Lc/видео.html
Or, maybe even this one on using Fetch with async/await since the syntax is so similar so can be easily adapted for Axios: ruclips.net/video/8JcCdp2Y4Q4/видео.html
Upload progress is a pain...
Unfortunately, at the current time Fetch does not support upload progress.
Until, then you're better off using ajax for a native solution (ruclips.net/video/9biknk9SecY/видео.html) or axios (ruclips.net/video/nC3ntJUQrAM/видео.html)