Im getting this error while developing react native mobile application.
fetchDB function will return a promise
fetchDB(key) {
try {
AsyncStorage.getItem(key, result => {
return result;
});
} catch (error) {
console.log(error);
}
}
}
fetching value from returned promise by using .then()
getUserName = () => {
var user = Storage.fetchDB("username");
user.then(res => {
alert(res);
});
};
its rendering the red screen with error
undefined is not an object