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

got undefined on set cookie response

Open rahultatvasoft opened this issue 5 years ago • 3 comments

@joeferraro

"react": "16.8.6", "react-native": "0.60.4", "react-native-cookies": "^3.3.0",

import CookieManager from 'react-native-cookies';

CookieManager.set({ name: 'myCookie', value: 'myValue', domain: 'some domain', origin: 'some origin', path: '/', version: '1', expiration: '2015-05-30T12:30:00.00-05:00' }).then((res) => { console.log('CookieManager.set =>', res); // undefined });

rahultatvasoft avatar Oct 25 '19 05:10 rahultatvasoft

I have the same issue with @rahultatvasoft. Any idea ? Thanks.

chauduong1192 avatar Oct 27 '19 05:10 chauduong1192

The set method in the native module returns nil in every situation (whether it was a success or not), that's why it returns undefined in JS.

You can see here: RNCookieManagerIOS.m / line 38 resolve(nil);

You can use the CookieManager.get and CookieManager.getAll (this one only on iOS) methods to get the cookies from storage and verify if the cookie was saved successfully.

krakz999 avatar Oct 30 '19 20:10 krakz999

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