[Vuejs]-How to import store to the Api layer? Got Webpack error

0👍

I saw and responded to this question on the Vue Help Forum a bit ago, so I will add it here as well.

Obviously missing some other code here. Where are you creating your Vue instance? And are you including your store object in your Vue instance options?

Here is an example ‘main.js’ from one of my Vue 2 (Vue CLI) apps:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import 'bootstrap/dist/css/bootstrap.css'

Vue.config.productionTip = false

new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')

If using Vue CLI and Single File Components, you can then access the store from any component with ‘this.$store’.

Leave a comment