Qu'est-ce qui ne va pas avec le code ci-dessous? J'ai une erreur "async is a reserved word", j'ai configuré Babel pour async/await.
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
})
}
}
}
J'ai même essayé ceci
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
})
}
}