Skip to content

Instantly share code, notes, and snippets.

@bhuvidya
Last active March 1, 2022 05:39
Show Gist options
  • Save bhuvidya/436f600f1b3553b806511aed8de88009 to your computer and use it in GitHub Desktop.
Save bhuvidya/436f600f1b3553b806511aed8de88009 to your computer and use it in GitHub Desktop.
nuxt.js tips and tricks

Data Stores

Access Router

Pass Multiple Params to Mutation

You need to pas as an object, as the mutation takes a simple payload. Calling:

commit('SET_ENTRY', { slug, entry: response.data })

Mutation definition:

SET_ENTRY(state, { slug, entry }) {
  ...
}

Router

Access from .vue file

this.$route

Access from data store .js

this.$router.currentRoute

Access from asyncData

async asyncData(context) {
  const query_params = context.route.query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment