I am using AsyncStorage
in my React Native application to store information about the user. The getItem()
function is asynchronous and requires me
try this option and you will not get the
Syntax Error: Await is a reserved word
async getData() {
return await AsyncStorage.getItem("@App:KEY");
}
You can try either add a then after your getItem
.
AsyncStorage.getItem("phoneNumber").then((value) => {
this.setState({"phoneNumber": value});
})
.then(res => {
//do something else
});
Or use await to wait the async
operation to finish
var value = await AsyncStorage.getItem(STORAGE_KEY);
//use value to do something else.