Javascript 在react native中获取存储的数据

Javascript 在react native中获取存储的数据,javascript,react-native,asyncstorage,Javascript,React Native,Asyncstorage,我正在尝试使用异步存储API使用异步函数恢复我的用户密码和id,只有当前代码不执行 async function getStoredDatas(){ try{ return { user: await AsyncStorage.getItem('@Store:user'), password: await AsyncStorage.getItem('@Store:password') }; } cat

我正在尝试使用异步存储API使用异步函数恢复我的用户密码和id,只有当前代码不执行

async function getStoredDatas(){
    try{
       return {
           user: await AsyncStorage.getItem('@Store:user'),
           password: await AsyncStorage.getItem('@Store:password')
       };
    }
    catch(e){
       console.log("error:" + e); // never triggered
    }
}

let a = getStoredDatas().then( (datas) => {
    console.log("then: " + datas.user); // never triggered also
});

console.log(a); // Promise with this content: {_40: 0, _65: 0, _55: null, _72: null}

解决方案如下:
AsyncStorage
模块仅在没有调试模式的情况下工作。

提供更多详细信息。您收到了哪一个错误?我没有收到任何错误,这可能是我的Javascript代码中的错误?您能否提供控制台日志上看到的屏幕截图。很难判断您提供的代码有什么问题您的javascript看起来很好。如果将
wait AsyncStorage.getItem('@Store:user')
赋值并在
返回之前记录,您会看到什么?AsyncStorage中可能没有设置项。以下是控制台的屏幕截图: