Question: I have a [vuex](https://vuex.vuejs.org/en/intro.html) store, like following:

```
import spreeApi from '../../gateways/spree-api'
// initial state
const state = {
  products: [],
  categories: []
}

// mutations
const mutations = {
 SET_PRODUCTS: (state, response) => {
   state.products = response.data.products
   commit('SET_CATEGORIES')
 },
 SET_CATEGORIES: (state) => {
   state.categories = state.products.map(function(product) { return product.category})
 }

}

const actions = {
 FETCH_PRODUCTS: (state, filters) => {
   return spreeApi.get('products').then(response => state.commit('SET_PRODUCTS', response))
 }
}

export default {
  state,
  mutations,
  actions
}

```

I want to call mutation: `SET_CATEGORIES` from mutation: `SET_PRODUCTS`, But this gives me error: 

> 
> projectFilter.js:22 Uncaught (in promise) ReferenceError: commit is not defined(…)
> 
> 
> 

What should be correct way to do this. I tried `store.commit` and `this.commit`, but these also gave similar errors.

Answer: 
**First, assign the Vue button to a variable:**
In main.js:

```
  export const app = new Vue({  
  router,
  vuetify,
  store,....

```

**Then import the "app" variable to the js file where you define the mutation:**
In modules.js:

```
import { app } from "../../main";

```

**You can now use it as "app.$store.commit":**

```
mutations: {
[AUTH_SET_TOKEN]: () => {
app.$store.commit(USER_SUCCESS, params );
},...

```
**Use this**

```
const mutations = {
 SET_PRODUCTS: (state, response) => {
   state.products = response.data.products
   this.commit('SET_CATEGORIES')
 },
 SET_CATEGORIES: (state) => {
   setCategories(state)
 }
}

```