Skip to content Skip to sidebar Skip to footer

Rest Api Call Works Only Once

I have written a Nodejs REST API application with a number of functions. However when I consume one of the APIs it returns me the excel file it is supposed to return and everything

Solution 1:

I finally fixed it by using the following lines:

 wb.write('Report.xlsx', res,function(){

           var filename = "Report.xlsx";
                res.setHeader('Content-disposition', 'attachment; filename=' + filename);
                res.setHeader('Content-type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                res.pipe(res);


});

Post a Comment for "Rest Api Call Works Only Once"