Nuxt.js: Are getters supported in modules mode?

Created on 6 Jun 2017  路  4Comments  路  Source: nuxt/nuxt.js

I don't see them mentioned here. Any advice would be much appreciated.

This question is available on Nuxt.js community (#c726)

Most helpful comment

You can access to your module getters through state.getters['the_module/the_getter'], ie: state.getters['user/isAuthenticated'].

All 4 comments

Yes they are supported, we don't mention them because it's like mutations or actions cases.

export const getters = {}

I guess they're a little awkward to interact with from within store/index.js

export const getters = {
  foo: state => {
    return 'bar'
  }
}

export const actions = {
  async DO_STUFF ({ dispatch, commit }) {
    console.log(`Doing stuff with: ${getters.foo()}`) // odd that this is called as a function
  }
}

Thanks.

You can access to your module getters through state.getters['the_module/the_getter'], ie: state.getters['user/isAuthenticated'].

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredreich picture jaredreich  路  3Comments

vadimsg picture vadimsg  路  3Comments

VincentLoy picture VincentLoy  路  3Comments

mikekidder picture mikekidder  路  3Comments

bimohxh picture bimohxh  路  3Comments