Answers for "nodejs set dns for request"

0

nodejs set dns for request

const { Resolver } = require('dns').promises;
const resolver = new Resolver();
resolver.setServers(['4.4.4.4']);

// This request will use the server at 4.4.4.4, independent of global settings.
resolver.resolve4('example.org').then((addresses) => {
  // ...
});

// Alternatively, the same code can be written using async-await style.
(async function() {
  const addresses = await resolver.resolve4('example.org');
})();
Posted by: Guest on March-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language