I want to put the token value in the maintoken through AsyncStorage. and the headers object in the mainheaders. However, when I run my code and run the getitems function, it writes to the console like this.
maintoken : eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjE2OTU5OTQ1NzIiLCJwcm92aWRlciI6Imtha2FvIiwiaWF0IjoxNjE4NTYyNzYyfQ.qnbFrRKxwL-9JK9O1aarTUvUYWnqU9pUNl2aO4IqGuc
mainheaders : [object Object]
The token value comes out well, but the mainheaders come out like this. How do I make the object come out?
this is my code
useEffect(() => {
Linking.addEventListener('url', async ({url}) => {
AsyncStorage.setItem(
'tokenstore',
JSON.stringify({
maintoken: `${token}`,
mainheaders: {
headers: {Authorization: `Bearer ${token}`},
},
}),
() => {
console.log('success');
},
);
});
return () => Linking.removeEventListener('url');
}, []);
const getitems = () => {
AsyncStorage.getItem('tokenstore', (err, result) => {
const UserInfo = JSON.parse(result);
console.log('maintoken : ' + UserInfo.maintoken); //
console.log('mainheaders :' + UserInfo.mainheaders); //
});
};
return (
<LoginButton onPress={() => getitems()}>
<Label>getItem</Label>
</LoginButton>
);