Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems that onDownloadProgress does not work in nodejs #928

Closed
micooz opened this issue May 31, 2017 · 6 comments
Closed

Seems that onDownloadProgress does not work in nodejs #928

micooz opened this issue May 31, 2017 · 6 comments

Comments

@micooz
Copy link

micooz commented May 31, 2017

#### Summary

In node.js:

(async () => {
  const response = await axios({
    method: 'get',
    url: 'https://github.com/mzabriskie/axios/blob/master/dist/axios.js',
    onDownloadProgress: (progressEvent) => {
      console.log(progressEvent); // seems never to be called
    },
    responseType: 'stream'
  });
  const stream = response.data;

})();

After I checked out the code, I found that onDownloadProgress is actually an event handler(xhr.js#151) of XMLHttpRequest which doesn't available in nodejs .

How can I get download progress in node.js? Is there any plan to make an implementation in node.js using http module?

#### Context

  • axios version: v0.16.1
  • Environment: node v7.10.0, chrome 57, ubuntu
@sen0rxol0
Copy link

sen0rxol0 commented Jun 1, 2017

is not only in node, it doesn't seem to be working on the browser either

@hielfx
Copy link

hielfx commented Jun 6, 2017

I am using the version v0.15.3 and it's working there. Also I am using Ubuntu 16.04, Node v6.9.1 and Chrome 58.0.3029.110 (64-bit), in case you want to try it on those versions

@rubennorte
Copy link
Member

onDownloadProgress only works in the browser indeed. That should be noticed in the documentation.

In this case you're using responseType: stream so you can implement the download progress by looking at the Content-Length response header and the dataevents in the stream you get in the response.

@dobeerman
Copy link

@rubennorte seems it not works in the browser. I gets total: 0 in the properties.

@athoscouto
Copy link

@rubennorte, any solution for file upload?

@jayenashar
Copy link

onDownloadProgress only works in the browser indeed. That should be noticed in the documentation.

was this added to the documentation? i tried using it and found it didn't work in node and don't see it in the documentation.

chinesedfan added a commit that referenced this issue Feb 26, 2020
Saw in #928 and #1966 that `onUploadProgress` and `onDownloadProgress` only work in the browser and was missing that from the README.

Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants