mrichar1 / jsonapi-vuex

Use a JSONAPI api with a Vuex store, with data restructuring/normalization.
GNU Affero General Public License v3.0
156 stars 23 forks source link

Using with nuxt #84

Closed ludo1960 closed 5 years ago

ludo1960 commented 5 years ago

Hello there,

I am following the advice given here to use your very nice module with nuxt. I created the jsonapi-vuex.js plugin and edited the nuxt config, I get the following error:

Could not find a declaration file for module 'jsonapi-vuex'. '/var/vue/nuxt2/node_modules/jsonapi-vuex/index.js' implicitly has an 'any' type. Try npm install @types/jsonapi-vuex if it exists or add a new declaration (.d.ts) file containing declare module 'jsonapi-vuex';ts(7016) Could not find a declaration file for module 'jsonapi-vuex'. '/var/vue/nuxt2/node_modules/jsonapi-vuex/index.js' implicitly has an 'any' type. Try npm install @types/jsonapi-vuex if it exists or add a new declaration (.d.ts) file containing declare module 'jsonapi-vuex';ts(7016)

I'm new to vue.js, I'm guessing I have to add your module to my config somewhere, but where?

ludo1960 commented 5 years ago

Answer was here https://github.com/mrichar1/jsonapi-vuex/issues/13

To summorise:

Create jsonapi-vuex.js in plugins directory:

`import { jsonapiModule } from 'jsonapi-vuex'

export default function({ $axios, store }) { store.registerModule('jv', jsonapiModule($axios)) } Make sure your nuxt.config.js has the following: plugins: [ '~/plugins/jsonapi-vuex.js' ], and: build: { /* ** You can extend webpack config here */ transpile: ['jsonapi-vuex'], extend (config, ctx) { } }