Skip to content

Infer responseType from response headers? #793

@reid3290

Description

@reid3290

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions