-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Description
Normally I'd try to dig more for an explanation, but I'm a bit confounded here. I'm doing some cookie construction / management by hand via tough-cookie
to maintain sessions for my API calls, and it looks like request
and request-promise
are giving me two different behaviors, where request
works but request-promise
does not.
The problematic code is as follows
const request = require('request');
const requestPromise = require('request-promise');
const tough = require('tough-cookie');
let sessionCookie = new tough.Cookie({
key: "some_key",
value: "some_value",
domain: 'api.mydomain.com',
httpOnly: true,
maxAge: 31536000
});
let cookiejar = request.jar();
cookiejar.setCookie(sessionCookie, 'https://api.mydomain.com'); // does not throw an error
let sessionCookie2 = new tough.Cookie({
key: "some_key",
value: "some_value",
domain: 'api.mydomain.com',
httpOnly: true,
maxAge: 31536000
});
let cookiejar2 = requestPromise.jar();
cookiejar2.setCookie(sessionCookie2, 'https://api.mydomain.com'); // TypeError: str.trim is not a function
Is it just a version/dependency thing? Am I just abusing the concept of cookie jars beyond repair?
From my package.json:
"request": "^2.81.0",
"request-promise": "^4.2.0",
"tough-cookie": "^2.3.2",
I'm leaving the request.jar()
patch in for now, but I'd love to know what's going wrong exactly
Thanks in advance,
Scotty
r-ohan, guillaumegarcia13, kapilchokhawala, T1MOXA, iperevozchikov and 5 more
Metadata
Metadata
Assignees
Labels
No labels