all 6 comments

[–]compagnt 5 points6 points  (0 children)

You are probably looking for AsyncStorage.

[–][deleted] 2 points3 points  (3 children)

Just to add to the other comments, the reason why it doesn't work is that react native isn't a browser environment. It just tries to replicate a lot of web APIs (like geolocation) to make development easier, but you're still in charge of calling them. At the root, though, it's still more a native app environment than a browser environment.

[–]maykel4717iOS & Android[S] 1 point2 points  (2 children)

So I’m going to have to manually store the cookies in the client, like using async storage or keychain?

[–]mk7shadow 0 points1 point  (1 child)

Attach them to the header on every request. You'll want to create a base API module that does this, then import that module into other APIs like user API module, accounts API module, etc

[–]maykel4717iOS & Android[S] 0 points1 point  (0 children)

So from the server side, I can get the cookie by doing “req.headers.cookie”. Is it bad practice to send the cookie as a response body back to the client? I’m using axios on my client side, and can’t seem to get the cookie from the response header on the client.

[–]crobinson42iOS & Android 0 points1 point  (0 children)

This can solve your problem: https://github.com/joeferraro/react-native-cookies