Contentful with Nuxt.JS "Expected parameter accessToken"

The best approach is used dotenv package to that. Set your env keys in .env file.

nuxt.config.js file should contain:

const env = require('dotenv').config()

export default {
  mode: 'universal',
  ...
  env: env.parsed,
  ...
}

Look at this video: https://codecourse.com/watch/using-env-files-with-nuxt


If you use dotenv you need to do following steps:

npm install --save-dev @nuxtjs/dotenv

Then you install it as an module. Note here if you using Nuxt.js older then v2.9 then you ahve to go to nuxt.config.js and put your code into the module section:

...
   module: [
   '@nuxtjs/dotenv'
 ]
...

If there is no module section then create one.

If you using newer then v2.9 then you put it into the buildModules

  ...
   buildModules: [
   '@nuxtjs/dotenv'
 ]
...

Your variables that are saved in the .env file are now accessable through context.env or process.env