Download from frontend as user


I’m pretty new in development and adonisjs is where I’m building my first large project.

I would like to make it possible for the users to download the data (ex. a list of all the users) from the frontend as a csv or xml file. Is there any built in functions in adonisjs to do this, or does anyone know a library or solution to do this?


I guess you can use something like this in your controller:


More details here:


Hi! I have the data I want the user to be able to download as a .csv file and I have converted my JSON response from the database to .csv format, then I want to create a file, save it to Helpers.tmpPath(some path) and then it gets downloaded to the user wit response.attachment(Helpers.tmpPath(some path)). Any solutions anyone?


Solved it like this:
convert JSON to csv with javascript function


response.header('Content-type', 'text/csv')
response.header('Content-Disposition', 'attachment; filename="users.csv"')