当我调用loginUser函数时,它假设访问SecureStore函数,而是返回axios.post方法。
知道这里出了什么问题吗?
import { SecureStore } from 'expo';
export function loginUser(email, password) {
return function (dispatch) {
return axios.post(SIGNIN_URL, { email, password }).then((response) => {
var { user_id, token } = response.data;
Expo.SecureStore.setItemAsync(user_id, password, options).then(function() {
dispatch(authUser(user_id));
console.log('I am in')
}).catch((error) => {
console.log('Its an error')
dispatch(addAlert("Could not log in."));
});
}).catch((error) => {
dispatch(addAlert("Could not log in."));
});
};
}
答案 0 :(得分:0)
问题在于您构建承诺链的方式。
const promiseOne = new Promise((resolve, reject) => {
resolve('p1')
})
const promiseTwo = new Promise((resolve, reject) => {
resolve('p2')
})
promiseOne.then(
(res) => {
console.log('res', res)
return promiseTwo
})
.then((res2) => {
console.log('res2', res2)
})
基本上,您需要将通话返回到Expo