无法使用axios下载zip文件

Unable to download zip file using axios

这是我使用的代码:

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

收到的响应数据是二进制的,我正在将其转换为 base64 并保存在文件中。 保存 zip 文件后。如果我尝试打开该文件,它会显示无效的 zip 错误。

您可以尝试将 responseType 添加为 arraybuffer

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