I have problem regarding on my AsyncStorage.getItem. I have module which is the login, where I need to set the item inside the storage, after I get the result there is an yellow message below that I have Error: java.lang.Double cannot be cast to java.lang.String I didn't know where the error came.
I will show you guys, my function to set the item in the storage.
if(response.status == '200')
{
AsyncStorage.setItem('authorization_code',access_token);
AsyncStorage.setItem('authorization_expiration',expires_in);
AsyncStorage.setItem('authorization_type',token_type);
//let token = AsyncStorage.getItem(JSON.stringify("authorization_code"));
AsyncStorage.getItem('authorization_code', (err, result) => {
alert(result);
});
}
Use toString()
to force type in js side. I suppose that is expires_in
the floating point number here, so:
AsyncStorage.setItem('authorization_code',access_token);
AsyncStorage.setItem('authorization_expiration',expires_in.toString());
AsyncStorage.setItem('authorization_type',token_type);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With