Reputation: 303
I am using Nuxt fetch()
lifecycle hook to fetch data from Vuex. My Store structure looks like this
store/
--| index.js
--| dialog.js
--| country/
------| actions.js // I want to use async call in this file
------| getters.js
------| mutations.js
------| state.js
In my component I am using fetch like this
async fetch({ store }){
await store.dispatch("country/fetchCountries")
},
My country/actions.js file look like this
export const fetchCountries = ({commit, dispatch}, form) => {
// let response = await this.$axios.get('/countries');
}
Now, I can not use async in front of the function. How can i use async in front of this function?
Upvotes: 0
Views: 306
Reputation: 46604
This one is not working ?
export const fetchCountries = async ({commit, dispatch}, form) => {
Upvotes: 1