title: how to get data from API in vuex using axios?
body: <p>I have data taken from API laravel, and here is my code in state.js</p>
  
  <pre><code>import axios from 'axios'
  import {apiPostGet} from '../api/api'
  export default {
    data: axios({
      method: 'GET',
      url: apiPostGet('Kategori')
    }).then(
      response =&gt; {
        return response.data.kategori
      }
    ).catch(
      error =&gt; {
        return error.response
      }
    )
  }
  </code></pre>
  
  <p>and this is my code in gteeters.js</p>
  
  <pre><code>export default {
    datas: state =&gt; {
      return state.data
    }
  }
  </code></pre>
  
  <p>and this is my code in index.js</p>
  
  <pre><code>import Vue from 'vue'
  import Vuex from 'vuex'
  import state from './state'
  import getters from './getters'
  
  Vue.use(Vuex)
  
  export default new Vuex.Store({
     state,
     getters
  })
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/UhBNw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UhBNw.png" alt="and this picture from dev tool vue js"></a></p>