Im using .then when getting item from Asyncstorage/localstorage. I want to use the item I get from storage, but can't because I only get the unresolved promise. Also, I cannot use async/await as Im not using it inside a function in my case.
const language = AsyncStorage.getItem('user').then(item => item).then(user => {
const lang = JSON.parse(user).lang;
console.log("item:", lang, typeof lang)
return lang;
});
console.log("language: ", language)
output:
language: Promise {
"_A": null,
"_x": 0,
"_y": 0,
"_z": null,
}
item: de