4

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?

1 Answer 1

9

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

AsyncStorage.getItem('JWT_Key', (err, item) => console.log(item));
Sign up to request clarification or add additional context in comments.

1 Comment

I still get the same [object object] even in the call back. Would you mind providing an example where you setItem with the key and then getItem with the key, so I can see it? My key is something like '@appSettings' but it's giving me such a hard time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.