[Vuejs]-Failed to compile. Syntax Error: Unexpected token in Vue.js

0๐Ÿ‘

โœ…

If you check the documentation for vuex 4.0 you can see that you are using createStore incorrectly (assuming that you are using ES2015 syntax). state should be a function returning your initial store state. Furthermore your syntax for the object properties is wrong. You need to use : instead of =.

So your code should be:

export default createStore({
     state () {
        return {
          isLoading: false,
          isAuthenticated: false,
          token: ''
        }
     }
})

Source: https://next.vuex.vuejs.org/guide/#the-simplest-store

Leave a comment