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

Expose xhr object on promise #290

Closed
wants to merge 1 commit into from
Closed

Conversation

olalonde
Copy link

@olalonde olalonde commented Mar 8, 2016

See issue #89

@dgraham
Copy link
Contributor

dgraham commented Mar 8, 2016

The XMLHttpRequest object is an implementation detail of this fetch implementation that cannot be exposed to callers.

@dgraham dgraham closed this Mar 8, 2016
@olalonde
Copy link
Author

olalonde commented Mar 8, 2016

@dgraham I understand that but is there any way to get upload progress event out of fetch? Can't seem to find any other than this hack.

@dgraham
Copy link
Contributor

dgraham commented Mar 8, 2016

Fetch doesn't support progress events, but XMLHttpRequest does.

var xhr = new XMLHttpRequest()
xhr.open('POST', '/uploads')
xhr.onload = function() {
  console.log(xhr.status, xhr.responseText)
}
xhr.onerror = function() {}
xhr.upload.onprogress = function (event) {
  if (event.lengthComputable) {
    var percent = Math.round((event.loaded / event.total) * 100)
    console.log(percent)
  }
}

@mislav mislav mentioned this pull request Mar 8, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 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

Successfully merging this pull request may close these issues.

None yet

2 participants