Javascript 如何在vuex模块中编写异步函数

Javascript 如何在vuex模块中编写异步函数,javascript,vue.js,nuxt.js,vuex,Javascript,Vue.js,Nuxt.js,Vuex,我正在使用Nuxt从Vuex获取数据。我的商店结构是这样的 store/ --| index.js --| dialog.js --| country/ ------| actions.js // I want to use async call in this file ------| getters.js ------| mutations.js ------| state.js export const fetchCountries = ({commit, dispatch},

我正在使用Nuxt从Vuex获取数据。我的商店结构是这样的

 store/
--| index.js
--| dialog.js
--| country/
------| actions.js    // I want to use async call in this file
------| getters.js
------| mutations.js
------| state.js 
export const fetchCountries = ({commit, dispatch}, form) => {

    // let response = await this.$axios.get('/countries'); 

}
在我的组件中,我像这样使用fetch

 store/
--| index.js
--| dialog.js
--| country/
------| actions.js    // I want to use async call in this file
------| getters.js
------| mutations.js
------| state.js 
export const fetchCountries = ({commit, dispatch}, form) => {

    // let response = await this.$axios.get('/countries'); 

}
异步获取({store}){
等待门店发货(“国家/地区”)
},
My country/actions.js文件如下所示

 store/
--| index.js
--| dialog.js
--| country/
------| actions.js    // I want to use async call in this file
------| getters.js
------| mutations.js
------| state.js 
export const fetchCountries = ({commit, dispatch}, form) => {

    // let response = await this.$axios.get('/countries'); 

}

现在,我不能在函数前面使用async。如何在此函数前面使用async?

此函数不起作用


export const fetchCountries=async({commit,dispatch},form)=>{

谢谢您的解决方案。它工作了,但出现了另一个问题。这。$axios不工作。但我找到了另一个解决方案。我将所有函数包装在
export default{async fetchCountries(){}