3

I have a report and I'm mounting this report using my application state data only. I format my data, and display it into a table.

Users should have the option of Downloading this data as CSV. I think creating a New API endpoint for this would be overkilling. Then I was thinking about exporting this in client-side, converting the JSON into CSV and sending this as a download to the user.

Is it a bad practice??? Should I use back-end rain or shine?

Gabriel S.
  • 167
  • 2
  • 10

1 Answers1

1

If the data is exactly the same as the other API endpoint, then I wouldn't create a new endpoint, but just accept and respond to Content-Type: text/csv .

However, doing it client side is totally acceptable and something I've done in the past.

PROS:

  • Reduced server load
  • No need to support a different content-type on your endpoint

CONS:

  • Wouldn't be available if you wanted if some other client wanted it
  • Depending on how you generate the csv, if the data changes you might need to update the client code.
  • Might be tough to get the download to work in old browsers
NSjonas
  • 10,693
  • 9
  • 66
  • 92