【发布时间】:2018-10-07 22:03:14
【问题描述】:
下面的代码有什么问题?我得到 async is a reserved word 错误,我为 async/await 配置了 babel。
export async function getCredit(){
return dispatch => {
try {
const creditInfo = await axios.get(`/credit`)
} catch (err) {
dispatch(errorMsg(err.data.msg))
}
if(creditInfo.result === 200 && res.data.status === 1) {
dispatch({
type: GET_CREDIT,
payload: creditInfo.data
})
}
}
}
我什至试过这个
export async getCredit() => dispatch => {
try {
const creditInfo = await axios.get(`/credit`)
} catch (err) {
dispatch(errorMsg(err.data.msg))
}
if(creditInfo.result === 200 && res.data.status === 1) {
dispatch({
type: GET_CREDIT,
payload: creditInfo.data
})
}
}
【问题讨论】:
标签: reactjs ecmascript-6 redux async-await