Comments (14)
The native
fetch()
API implemented by browsers does not use XMLHttpRequest underneath.
But yet, it does not mean it couldn't be pondered and proposed.
Native promises are not yet cancellable and/or progressed, so my proposal would be for a callback on the second argument object of fetch
which would receive a ProgressEvent
(which is already present because of XHR).
As a polyfill, it could be easily placed with the progress
event listener as stated by the OP.
API Example:
aync fetchSometing ( form ) {
const res = await fetch('/upload', {
method: 'POST',
body: form,
progress: (e) => { console.log(`Progress: ${e.loaded/e.total}%`) }
})
}
from fetch.
Please reopen this issue. This is real world scenario on millions of websites daily. Fetch needs needs an upload progress. period. We've been stuck with the bad XHR API for decades now.
Yet, no one seems concerned that despite all the efforts and years of debates that went into fetch it does not deliver.
Can everyone on this committee stop treating it as a hot potato a deal with it.
from fetch.
The native fetch()
API implemented by browsers does not use XMLHttpRequest underneath. The eventual API for progress is building something on https://streams.spec.whatwg.org/ which https://github.com/yutakahirano/fetch-with-streams/ is adding to fetch()
.
from fetch.
Discussion around fetch observation is over at #447.
from fetch.
https://github.com/AnthumChris/fetch-progress-indicators
from fetch.
Ah, thanks for pinging this thread. Observation moved to #607. Hope that helps.
from fetch.
There is no committee… And this issue is closed because there is a more focused issue around a concrete proposal towards addressing this.
from fetch.
No thanks, I like my batteries included.
from fetch.
It can be done if browsers will start support ReadableStream for Request object's body.
Currently there is only support of ReadableStream for Response object's body and you can use it for checking download progress.
They should implement that:
https://fetch.spec.whatwg.org/#bodyinit
Check your browser:
https://w3c-test.org/fetch/api/basic/request-upload.any.html
So, waiting for the browser support, in this case you even do not need something like this: #607
See also: #425
from fetch.
@xgqfrms I only see download progress, where is upload progress ?
@annevk What proposal are you talking about? Can you post a link?
from fetch.
So why @cusspvz's idea doesn't seem to have been taken in consideration ?
It seems a good idea to me.
from fetch.
The discussion in #447 was more about fetch cancellation, now it's added in the spec with AbortController
For fetch upload progress, it would be great, that's the only missing thing compared to XHR
from fetch.
@oliverjanik Use the .on('progress', ...... )
feature of Superagent. https://github.com/visionmedia/superagent
from fetch.
from fetch.
Related Issues (20)
- RequestInit::priority lacks corresponding Request::priority attribute
- Referrer determination should be done on updated URLs in main fetch
- Automatic decompression should sanitize `Content-Encoding` and `Content-Length` headers from the response HOT 1
- When there is an issue with the URL parameter, fetch does not have any errors
- add a method to get a Uint8Array to Body HOT 4
- Fetch with Flask or Microdot HOT 1
- Service worker "handle fetch" seems to assume it's called in parallel HOT 2
- Redirect loop handling not discussed
- Add compression dictionary negotiation and decoding to the fetch processing model HOT 2
- Reconsider default Accept values for images
- Fetch support for explicit resource management
- Consider renaming or replacing http3only? HOT 1
- [render-blocking] The links of "render-blocking" in fetch are vague HOT 2
- Define what consequences NULL bytes (0x00) or other invalid values in header names have HOT 1
- 0x00 byte (%00) in a data: URL
- fetch does not allow caching requests with a null client HOT 1
- Question about stream handling around fetch requests with integrity metadata HOT 3
- Allow `new Response` with 101 status code HOT 6
- Question regarding preflight requests using the original request destination HOT 1
- Expected behavior of Response.redirect(null)? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fetch.