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: 
When you are already doing a mutation, there is no way to `commit` another mutation. A mutation is a synchronous call which changes the state. Within one mutation, you will not be able to commit another mutation.

Here is the API reference for Vuex: <https://vuex.vuejs.org/en/api.html>

As you can see, a mutation handler receives only `state` and `payload`, nothing more. Therefore you are getting `commit` as `undefined`.

In your case above, you can set the PRODUCT and CATEGORIES as part of the same mutation handler as a single commit. You can try if the following code works:

```js
// mutations
const mutations = {
    SET_PRODUCTS_AND_CATEGORIES: (state, response) => {
        state.products = response.data.products
        state.categories = state.products.map(function(product) { return product.category})
    },
    // ...
}

```

**EDIT:** Please refer to the answer below, provided by *Daniel S. Deboer*. The correct method is to commit two mutations from a single action, as described in his [answer](https://stackoverflow.com/a/43147938/10839134).
I prefer to call `mutations.SET_CATEGORIES(state)` instead of:
- calling 2 different commits from an artificial **action**
- or doing `commit()` inside a mutation as it makes unit testing more difficult.

```
const mutations = {
 SET_PRODUCTS: (state, response) => {
   state.products = response.data.products
   mutations.SET_CATEGORIES(state)
 },
 SET_CATEGORIES: (state) => {
   state.categories = state.products.map(product => product.category)
 }
}

```

My opinion is that you don't need to see `SET_CATEGORIES` in the VueToolbox. The time travel should work anyways. Please, correct me if I'm wrong.