What I have tried is below:
exports.downloadListOfUsers = (req, res) => {
let users = [{id:'',name:'',lastName:'',gender:''},{...},{...}]
const XLSX = require('xlsx');
let ws = XLSX.utils.aoa_to_sheet(users); //XLSZ.utils.json_to_sheet(users)
let wb = XLSX.utils.book_new();
let wbout = XLSX.write(wb, {bookType: 'xlsx', type: 'binary'});
wbout.pipe(res)
}
After sending it to the client, the response status is pending and it gets failed after some time. I have no idea what I am missing. Please guide me. Thanks.