Answer the question
In order to leave comments, you need to log in
How to fetch cookies from another site's response using node-fetch?
The bottom line is that I use the node-fetch module all over the place to parse the site.
But it doesn't return the same data to me that I can get using the request module.
Perhaps I have an error in the code that I did not take into account, or is it still better to switch to another module?
request:
var options = { method: 'POST',
url: 'https://siteurl/login.php',
headers:
{ 'cache-control': 'no-cache',
'content-type': 'multipart/form-data;' },
formData:
{ username: 'name',
password: 'pass',
autologin: 'on', } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(response.headers['set-cookie']);
});
const form = new FormData();
form.append('username', 'name');
form.append('password', 'pass');
form.append('autologin', 'on');
fetch('https://siteurl/login.php', { method: 'POST', body: form})
.then(response => response.headers.get('set-cookie'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question