GithubHelp home page GithubHelp logo

upload progress? about fetch HOT 14 CLOSED

radubrehar avatar radubrehar commented on August 15, 2024 26
upload progress?

from fetch.

Comments (14)

cusspvz avatar cusspvz commented on August 15, 2024 32

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.

oliverjanik avatar oliverjanik commented on August 15, 2024 21

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.

annevk avatar annevk commented on August 15, 2024 10

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.

jakearchibald avatar jakearchibald commented on August 15, 2024 7

Discussion around fetch observation is over at #447.

from fetch.

xgqfrms avatar xgqfrms commented on August 15, 2024 4

https://github.com/AnthumChris/fetch-progress-indicators

from fetch.

annevk avatar annevk commented on August 15, 2024 2

Ah, thanks for pinging this thread. Observation moved to #607. Hope that helps.

from fetch.

annevk avatar annevk commented on August 15, 2024 2

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.

oliverjanik avatar oliverjanik commented on August 15, 2024 2

No thanks, I like my batteries included.

from fetch.

TestPolygon avatar TestPolygon commented on August 15, 2024 2

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.

oliverjanik avatar oliverjanik commented on August 15, 2024 1

@xgqfrms I only see download progress, where is upload progress ?

@annevk What proposal are you talking about? Can you post a link?

from fetch.

ilan-schemoul avatar ilan-schemoul commented on August 15, 2024

So why @cusspvz's idea doesn't seem to have been taken in consideration ?
It seems a good idea to me.

from fetch.

caub avatar caub commented on August 15, 2024

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.

mindtonic avatar mindtonic commented on August 15, 2024

@oliverjanik Use the .on('progress', ...... ) feature of Superagent. https://github.com/visionmedia/superagent

from fetch.

annevk avatar annevk commented on August 15, 2024

#21 (comment)

from fetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.