[Vuejs]-Unable to use API key as env variable with Butter CMS library inside asyncData()

0👍

You are importing butter class from buttercms module in your component. But its not initialized. You can put your initialization into plugins/buttercms.js and add it into nuxt.config into plugin section.

import Butter from 'buttercms'

export default (ctx, inject) => {
  inject('butter', Butter(process.env.API_KEY))
}

And then you can reference initialzied instance via this.$butter in your components

Leave a comment