express - API return data in CSV format -
i'm creating api should return data in csv format. set content-type header text/csv forces download of contents csv file.
i'm using nodejs , express framework. standard behaviour. know how guys solved issue.
this sample of code i'm using:
res.set('content-type', 'text/csv'); var tocsv = require('to-csv'); // obj standard javascript object. res.send(tocsv(obj));
i person using api can retrieve data in csv format without downloading file
maybe have @ question: how browser determine whether download or show
it's browser decides content of type "text/csv" should downloaded.
you should consider using content-type, if want csv show in browser plain text.
try instead:
res.set('content-type', 'text/plain');
Comments
Post a Comment