![]() |
VOOZH | about |
The
dnsPromises.resolve() method
is an inbuilt application programming interface of the promises object of dns module which is used to resolve hostname into an array of the resource records.
Syntax:
dnsPromises.resolve( hostname, rrtype )Parameters:
This method has two parameters as mentioned above and described below:
Return Value:
This method returns error, records. Below examples illustrate the use of
dnsPromises.resolve() method
in Node.js:
Example 1:
Output:
[ 'ns-869.awsdns-44.net',
'ns-245.awsdns-30.com',
'ns-1520.awsdns-62.org',
'ns-1569.awsdns-04.co.uk' ]
Example 2:
Output:
from async:
[ { exchange: 'alt2.aspmx.l.google.com', priority: 5 },
{ exchange: 'aspmx.l.google.com', priority: 1 },
{ exchange: 'alt3.aspmx.l.google.com', priority: 10 },
{ exchange: 'alt4.aspmx.l.google.com', priority: 10 },
{ exchange: 'alt1.aspmx.l.google.com', priority: 5 }
]
Example 3:
Output:
[ '8.8.8.8' ]
Example 4:
Output:
(node:12752) ExperimentalWarning: The dns.promises API is experimental
[ [ 'v=spf1 include:amazonses.com include:_spf.google.com -all' ],
[ 'fob1m1abcdp777bf2ncvnjm08n' ] ]
Note:
The above program will compile and run by using the
node index.js
command.
Reference:
https://nodejs.org/api/dns.html#dns_dnspromises_resolve_hostname_rrtype