Giter Site home page Giter Site logo

Comments (9)

mrichar1 avatar mrichar1 commented on June 1, 2024

Can you provide the exact error, and what is reporting it? I can see that state could be a function, and there is support for this in the Vuex code, but I'm surprised that it is implying that using an object is 'wrong' when this is shown in all the docs - e.g. https://vuex.vuejs.org/guide/

I assume you creates jv.js just to implement this workaround, and that normally you are using jsonapiModule as a module in a new Vuex.store instance?

from jsonapi-vuex.

saiqulhaq avatar saiqulhaq commented on June 1, 2024

I think because I use namespaced vuex. I found this on SO https://stackoverflow.com/questions/49557177/vuex-state-returned-as-function-or-object-literal

from jsonapi-vuex.

mrichar1 avatar mrichar1 commented on June 1, 2024

Can you show me the contents of your store.js and/or wherever you instantiate jsonapiModule - I can see why this warning might be occurring, but I'd like to be able to reproduce it for the test suite before implementing any code changes, and everything I've tried with namespaces, nested modules etc 'just works' in the testapp so far...

from jsonapi-vuex.

saiqulhaq avatar saiqulhaq commented on June 1, 2024

OK
it's like this

import axios from 'axios'
import humps from 'humps'
import { jsonapiModule } from 'jsonapi-vuex'
import { loadProgressBar } from 'axios-progress-bar'

const api = axios.create({
  baseURL: process.env.NUXT_ENV_API_URL,
  headers: {
 //
 },
  transformResponse: [
    ...axios.defaults.transformResponse,
    (data) => humps.camelizeKeys(data)
  ],
  transformRequest: [
    ...axios.defaults.transformRequest,
    (data) => humps.decamelizeKeys(data)
  ]
})

loadProgressBar({ showSpinner: true }, api)

const jsonApi = jsonapiModule(api)

export default {
  ...jsonApi,
  state: () => {
    return jsonApi.state
  }
}

from jsonapi-vuex.

mrichar1 avatar mrichar1 commented on June 1, 2024

Thanks for the update.

It looks like this is likely caused by importing and then 're-exporting' jsonapi-vuex. I assume somewhere else you are importing this module and then using it in new Vuex.store() - i.e something like:

import { jsonApi } from './jv'

export default new Vuex.Store({
  modules: {
    jv: jsonApi
  }
}

Do you have a specific reason for re-exporting like this, and not just using jsonapiModule 'directly' in Vuex.store() ?

from jsonapi-vuex.

saiqulhaq avatar saiqulhaq commented on June 1, 2024

it's because Nuxt architecture https://nuxtjs.org/guide/vuex-store/

from jsonapi-vuex.

mrichar1 avatar mrichar1 commented on June 1, 2024

Ah, haven't used Nuxt but given their docs expects state as a function, that seems a good enough reason to make the modification, since it shouldn't affect 'vanilla' Vuex users.

I'll see about getting that change done soon!

from jsonapi-vuex.

mrichar1 avatar mrichar1 commented on June 1, 2024

Done - please try upgrading to 4.4.0 and seeing if that fixes the error!

from jsonapi-vuex.

stale avatar stale commented on June 1, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from jsonapi-vuex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.