So, when I make a GET request in postman, in the response, one cookie was generated. I am trying to do this request with axios in Node.js. However, I am not able to get this generated cookie.
I am using axios interceptors like:
axios.interceptors.response.use(function (response) {
console.log(response.headers);
return response;
}, function (error) {
return Promise.reject(error);
});
But, it only returns:
{
'cache-control': 'private',
'content-type': 'text/html',
expires: 'Tue, 01 Mar 2022 19:53:24 GMT',
server: 'Microsoft-IIS/8.5',
'x-powered-by': 'ASP.NET',
date: 'Tue, 01 Mar 2022 19:53:23 GMT',
'content-length': '4067'
}
I make the request like this
var config = {
method: 'get',
url: 'example.com',
headers: {
'Cookie': 'ASPSESSIONIDAWSQAQSA=AKLJADOCJNNPPHOKGGMOPHJD'
}
};
axios(config)
.then(function (response) {
//console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
There are more things in the header. But I just took it out to make it less verbose.
In the headers, there is no information about the cookie that is being generated. The problem is that I need this cookie to make other requests in the website.
In the request I already add one cookie like
{
'Cookie': 'ASPSESSIONIDAWSQAQSA=AKLJADOCJNNPPHOKGGMOPHJD',
'Connection': 'keep-alive'
}
But I need the new cookie that is generated in the response. Therefore, the next request that I do will have two cookies.