sunil ts
sunil ts

Reputation: 255

Unable to download zip file using axios

This is the code I use:

axios.get(fileUrl, {headers:{'X-API-TOKEN':xxxxxx})

Response data received is in binary, Which I am converting to base64 and saving in file. After saving zip file. If I try to open the file, it says invalid zip error.

Upvotes: 13

Views: 19718

Answers (1)

Pram
Pram

Reputation: 2501

You can try adding responseType as arraybuffer

axios.get(
   fileUrl,
   {headers:{'X-API-TOKEN':xxxxx}, responseType: 'arraybuffer'}
);

Upvotes: 42

Related Questions