react-native-cookies icon indicating copy to clipboard operation
react-native-cookies copied to clipboard

Blank object for cookie (Android)

Open Noitidart opened this issue 6 years ago • 2 comments

I'm on Android. I have the following code:

const res = await fetch('http://localhost:1337/user/me');
console.log('set-cookie:', res.headers.get('set-cookie')); // logs "sails.sid=s%3A6RiJhdKbjT9fkF7Ydozik61MCtmjcLCD.WyT8fXThP0C0Vqay86cmeD4Tn5Wl4aiJ1oFCo0HMRcQ; Path=/; HttpOnly"
console.log('get cookie:', CookieManager.get('http://localhost:1337')); // logs empty object {}

Does anyone know why I'm getting an empty object? The fetch did definitely succesfully set the cookie as I can do other calls after this first fetch.

Noitidart avatar Apr 21 '19 06:04 Noitidart

They are actually async calls so you have to handle them as such

VladyslavKochetkov avatar Jun 28 '19 21:06 VladyslavKochetkov

I have forked the repo here: https://github.com/safaiyeh/react-native-cookie-store We can create issues and PRs there to continue the development of the project.

safaiyeh avatar Jan 02 '20 19:01 safaiyeh