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); }, } }); });
We transform challenges into digital experiences
Get in touch to let us know what you’re looking for. Our policy includes 14 days risk-free!
Free project consultation