I am trying to make a Get-Request in Node.js.
const request = require( 'request' ).defaults({rejectUnauthorized:false});
request.get("https://some.url/", (err, req, body) => {
if (err) {
console.log(err);
} else {
console.log(body);
}
});
The problem is, that this does not use the user's default DNS servers (which are 8.8.8.8 and 8.8.4.4 in my case).
How can I make it use the users default DNS?
Or how can I tell it to always use a specific DNS (like 8.8.8.8)?
I tried doing
const dns = require("dns");
dns.setServers(["8.8.8.8", "8.8.4.4"]);
but that did not help.
If you have a solution using any other webscraping-capable package, for example 'node-fetch' or the standard 'https', feel free to post. I am willing to switch from 'request', as that is deprecated anyway.