0👍
You have to use the package dotenv. Then on the first line of nuxt.config.js:
require("dotenv").config()
And here is my axios setup in nuxt.config.js:
/*
** Axios configuration
*/
axios: {
// See https://github.com/nuxt-community/axios-module#options
baseURL: process.env.BASE_URL,
headers: {
common: {
Accept: "application/json"
}
}
},
This works fine for me. If you still can’t recieve the API data, check in the network tab from the Developer Tools. Check if any request is fired and if so, check the url and possible response if there is any.
Source:stackexchange.com