Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie seems not working #4

Closed
RuoanJi opened this issue Feb 24, 2014 · 6 comments
Closed

Cookie seems not working #4

RuoanJi opened this issue Feb 24, 2014 · 6 comments

Comments

@RuoanJi
Copy link

RuoanJi commented Feb 24, 2014

Hi,
I chose Node.js over Java, trying to have some fun.
I found this awesome library on Internet, but with limited documentation, it's really difficult to explore (Sometimes I look into the source code and nail it, but I'm not familiar with the "http" package.).
Here's the issue:
When I copy and paste the very code from readme,

var CookieJar = unirest.jar();
CookieJar.add(unirest.cookie('some value'));
unirest.get('http://httpbin.org/get').jar(CookieJar);

something go wrong

CookieJar.add(unirest.cookie('some value'));
^
TypeError: Object # has no method 'add'

I wish to implement a login module and then keep the cookie so that I can do something with it .
How can I do that?

Best Regards,
Rowan

@nijikokun
Copy link
Contributor

I cannot replicate this, can you post how you are attempting to use this?

@RuoanJi
Copy link
Author

RuoanJi commented Feb 25, 2014

I nailed it by manually concat the cookie string and set it in the header, anyway, it works.

The problem remains. It's extremely easy for me to replicate it by simply putting these four lines in an empty file:

var unirest = require('unirest');

var CookieJar = unirest.jar();
CookieJar.add(unirest.cookie('some value'));
unirest.get('http://httpbin.org/get').jar(CookieJar);

And it turns out:

/xxxx/test.js:4
CookieJar.add(unirest.cookie('some value'));
^
TypeError: Object # has no method 'add'
at Object. (/xxx/test.js:4:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3

@RuoanJi
Copy link
Author

RuoanJi commented Feb 25, 2014

By the way, I'm working on OS X 10.6, Node.js v0.10.23 and I also installed automata in the same workspace.

Everything else with unirest is just fine. Thanks for your great job.

@indus
Copy link

indus commented Feb 27, 2014

same here!

CookieJar is just a simple object...

var CookieJar = unirest.jar(); // { _jar: { store: { idx: {} } } }

...there is no 'add' function at all.

(working on Windows 7; Node.js v0.8.9)

@nijikokun
Copy link
Contributor

Hmm, Alright, I will look more into it, can you guys tell me what you are specifically doing?

@nijikokun
Copy link
Contributor

You guys are right, the merge that happened recently broke the cookiejar, I have restored it to it's glory in 0.1.8 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants