Static GitHub Issues

[123] What is the best way to load json.

prev: How to add custom resolve.alias in nuxt.config.js
next: Feathers.js

I have a json file with data to initialise my pages. I put it in /static folder e.g. /static/data.json. Then I use axios.get() to load it from /data.json. That works on the client, but fails on the server.

I have these questions, which I think will be very useful for wider audience as well: 1. What is wrong with the example below? 2. Is /static the best place to put data files? 3. is loading them via axios the best way ? 4. What if I want to load from 3 different locations for server, for client and for static build?

 export default {
    data({ req, params, store }) {
      
      return axios.get('/data.json')
        .then((res) => {
          return {
            authors: res.data
          }
        })
    }
  }

Thanks in advance

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c100">#c100</a>)</em></sub></div>