有一段代码如下:
useEffect(() => {
const checkLoginStatus = async () => {
try {
const token = AsyncStorage.getItem('authToken')
if (token) {
router.replace('/(tabs)/home')
}
} catch (error) {
console.log(error)
}
}
checkLoginStatus()
}, [])
返回的token是{"_h": 0, "_i": 0, "_j": null, "_k": null}
后来发现asyncstorage是异步call,需要在前面加上await,否则就会返回这个对象,意思就是pending promise的意思……
最新回复