react-native-cookies
react-native-cookies copied to clipboard
Blank object for cookie (Android)
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.
They are actually async calls so you have to handle them as such
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.