-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Infer responseType from response headers? #793
Copy link
Copy link
Closed
Description
I wanted to use axios to download a image from the server. At the beginning I try to do this:
axios.get(url).then(response=>fs.writeFile(filename, response.data));
But obviously the image downloaded is broken. Then I toke a lot of time to go over the whole document and figure it out I have to set the responseType manully:
axios.get(url,{
responseType: 'stream'
}).then(response=>response.data.pipe(fs.createWriteStream(filename)));
Is there any chance that axios can figure reponseType out automatically?
If it can't, I think it's better to make it more clear in the doc(expecially what does stream mean, as well as blob and buffer).
Thx
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels