[Vuejs]-How and where should I keep CSV data file in nuxt.js project so that CSV data can be rendered easiliy on page/template?

1👍

It really depends on your data, your setup and experience…

If your data is not changing too often and you are willing to build and deploy your app every time it changes, the simplest thing you can do is to convert csv to json and include myData from myData.json directly from JavaScript (and keep it in the same folder as your component)

  • data will by part of your app bundle (ok if its just few lines)
  • works great with static site (nuxt generate) or SPA mode of Nuxt (don’t need Node on server side so it can be hosted on Netlify and such)
  • simple

Other option is to put in inside static folder but then you will need to download it into your running app at run-time using Ajax (Axios for example). You can find examples here

  • more complicated
  • ability to update data without building whole app (just upload single file)

Even in this second case I would argue its better to parse it once and convert into something JavaScript can read easily (like JSON) and keep it that way instead of parsing at run-time every time someone uses your site…

Leave a comment