我无法完成这项工作......它说:await 是一个保留字。是的,当然是......而且我想使用它:)
怎么了 ?
export const loginWithToken = async () => {
return dispatch => {
dispatch({type: SESSION_LOGIN_IN_PROGRESS, payload: true})
let storedData = await ReadFromLocalDB('user')
console.log(storedData)
if (!storedData) {
invalidToken(null, dispatch)
}
else {
storedData = JSON.parse(storedData)
SessionLoginWithToken(storedData.session.token).then(res => {
console.log(res)
loginSuccessfully(res, dispatch, true)
})
}
}
}
我的ReadFromLocalDB
功能是这样的:
export const ReadFromLocalDB = async (key) => {
return AsyncStorage.getItem(key)
}
它返回一个Promise