Unable to download zip file using axios

Viewed 16298

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.

1 Answers

You can try adding responseType as arraybuffer

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