Skip to content

How can i transfer my res.data to Uint8Array #264

Answered by jimmywarting
broairport asked this question in Q&A
Discussion options

You must be logged in to vote

I would recommend against using axios...

why?

  • b/c axios uses XMLHttpRequest to get data. (ref)
  • xhr don't support streaming.
  • axios weighs as much as 6.2 kB when minified
  • axios don't work within web workers either...
  • when you are using xhr to get data then you download everything into memory.
  • using xhr beats the whole purpose of using streamsaver as it's meant to save you from allocating everything into memory.

only fetch supports streaming...

fetch(url).then(res => {
  res.body.pipeTo(destination)
})

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@broairport
Comment options

@jimmywarting
Comment options

@jimmywarting
Comment options

@broairport
Comment options

@broairport
Comment options

Answer selected by broairport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #263 on January 18, 2022 19:25.