nodejs
Download streamable files with Axios/NestJS
Solution
Use responseType: arraybuffer
. Example in NestJS (The httpService
of NestJS uses Axios):
const response = this.httpService.get(downloadUrl, { responseType: 'arraybuffer', // <= THIS }); return new Promise((resolve, reject) => { response.subscribe({ next(response) { response.status === 200 ? resolve(response.data) : reject(response.data); }, error(err) { reject(err); }, } }); });