Reputation: 4783
I'm trying to add a cookie to request.js module (https://github.com/mikeal/request) but I got lost
Does any one have some experience with this ?
The code I've is :
var j = request.jar();
var cookie = request.cookie('TENANTID');
j.setCookie(cookie, 'public');
var requestSettings = {
method: self.method[m],
url: url.format({
pathname : self.getServer() + u,
query: {tenant: (process.env.STORM_DB_TENANTS_NAME || 'public')}
}),
headers: {'Content-Type': self.headers[h]},
jar : true
};
The question is how do I combine them ?
Upvotes: 1
Views: 359
Reputation: 292
in you requestSettings
you need to assign jar: j
instead of jar: true
.
So your requestSettings
would look like this:
var requestSettings = {
method: self.method[m],
url: url.format({
pathname : self.getServer() + u,
query: {tenant: (process.env.STORM_DB_TENANTS_NAME || 'public')}
}),
headers: {'Content-Type': self.headers[h]},
jar : j // The request.jar() object you created and added the cookie to.
};
Upvotes: 2