How to publish CSV data via an API?

All packages I found export JSON. I want to import to Google Spreadsheets (which needs CSV).

1 Like

I used this to great effect last week: https://github.com/zemirco/json2csv

I had 45k rows to write and it handled it like a champ.

Interesting package. However, I already have the csv string. I just want to publish it via an API.
When I use e.g. simple:rest it wraps my CSV data in JSON.

I think you can probably do this with simple:rest as well but using nimble:restivus you can write data directly to the response object, ala https://github.com/kahmali/meteor-restivus#endpoint-context

Then within your custom endpoint, add something like this:

this.response.setHeader('Content-Type', 'text/csv');
this.response.write(csvdata);
this.done()

It works!

Thank you so much.