denden
denden

Reputation: 1319

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?

Upvotes: 4

Views: 3928

Answers (1)

Matt Aft
Matt Aft

Reputation: 8936

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

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

Upvotes: 9

Related Questions