про банку я понял, меня смущает обьект
qs: {
testCookie1: "first",
testCookie2: "second"
}
как мне добавить параметры
domain или path
?
попробуй
let cookiejar = new tough.CookieJar();
const agentOptions = {
host: FRONT_DOMAIN,
port: '443',
path: '/',
rejectUnauthorized: false
};
const agent = new https.Agent(agentOptions);
async function getCookie() {
let option = {
method: 'GET',
uri: FRONT_DOMAIN,
resolveWithFullResponse: true
};
if (FRONT_DOMAIN.includes('staging'))
option.agent = agent;
const result = await rp(option);
const index = result.headers['set-cookie'].findIndex(str => str.includes('PHPSESSID'));
const Cookie = tough.Cookie;
const cookie = Cookie.parse(result.headers['set-cookie'][index]);
cookiejar = rp.jar();
cookiejar.setCookie(cookie.cookieString(), FRONT_DOMAIN);
console.log(Cookie set successfully, cookie is ${cookie.cookieString()}
);
}
...
и дальше юзаешь в другие реквестах
const option = {
jar: cookiejar
...}
тут усложнено, т.к. код юзается на дев и стейджинге