I'm using react-native-async-storage for saving API headers and user information received from API
const storeUserInfo = async (userInfo: any, headers: any) => {
console.log(
'Info Received in Local Storage Function',
userInfo,
'Headers Received in Local Storage Function',
headers,
);
try {
const user = JSON.stringify(userInfo);
const userheaders = JSON.stringify(headers);
await AsyncStorage.setItem('user', user);
await AsyncStorage.setItem('headers', userheaders);
} catch (e) {
console.log('Error while storing user info', e);
}
};
when i try to get headers from async-storage, it gave old stored headers rather than returning latest.
// Getting headers like this..
const headers = await AsyncStorage.getItem('headers');
console.log('Headers received in get Profile Action', headers);
but it returning old headers..