There is way to use ".then callback" to console.log the "frog" coz i wanna see my token inside the async-storage.
---after i got my token so i need to attach it in header of a fetch call, someone know the way to do it?
useEffect(() => {
const frog = AsyncStorage.getItem('AZURE-TOKEN');
console.log('THIS MY TOKEN', frog);
}, []);
I'm not sure, but maybe you can simply do
useEffect(() => {
const getItem = async () => {
const frog = await AsyncStorage.getItem('AZURE-TOKEN');
console.log('THIS MY TOKEN', frog);
};
getItem();
}, []);
or
useEffect(() => {
AsyncStorage.getItem('AZURE-TOKEN')
.then(token => {
console.log('THIS MY TOKEN', token);
});
}, []);
In the first case, I'm creating an async function, enabling in this way the await
keyword, in the second case I'm simply using then
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.