Search code examples
react-nativeasyncstorage

AsyncStorage returns [Object] [Object]


I'm tinkering with using JSON web token for authentication at the moment, between a react-native app and an express/passport-jwt server.

I can check credentials/login from the app to server no problem and as the key is returned from server to app, I can console.log(response.token) it on the app console.

I then save it with AsyncStorage.setItem('JWT_Key', response.token)

My issue is that when I return it using something like console.log(AsyncStorage.getItem('JWT_Key')) it returns [Object] [Object]

I can't seem to see anything in the docs, can someone tell me what am I missing?


Solution

  • AsyncStorage returns a promise, but you can also just grab the item through a callback:

    AsyncStorage.getItem('JWT_Key', (err, item) => console.log(item));