Node.js dnsPromises.resolveSoa() Method
Last Updated :
13 Oct, 2021
The dnsPromises.resolveSoa() method is an inbuilt application programming interface of the promises object of dns module which is used to resolve SOA or start of authority records for the specified hostname using DNS protocol.
Syntax:
dnsPromises.resolveSoa( hostname )
Parameters: This method has one parameter as mentioned above and described below:
- hostname: This parameter specifies a string which denotes the hostname to be resolved.
Return Value: This method returns error, addresses. The address parameter will contain nsname, hostmaster, serial, refresh, retry, expire and minttl properties.
Below examples illustrate the use of dnsPromises.resolveSoa() method in Node.js:
Example 1:
const dns = require( 'dns' );
const dnsPromises = dns.promises;
dnsPromises.resolveSoa( 'google.com' ).then((res) => {
console.log( "for google : " );
console.log(res);
});
|
Output:
for google :
{ nsname: 'ns1.google.com',
hostmaster: 'dns-admin.google.com',
serial: 290031082,
refresh: 900,
retry: 900,
expire: 1800,
minttl: 60
}
Example 2:
const dns = require( 'dns' );
const dnsPromises = dns.promises;
(async function () {
const records = await dnsPromises.resolveSoa(
'geeksforgeeks.org' );
console.log( "from async: " );
console.log(records);
})();
|
Output:
from async:
{ nsname: 'ns-869.awsdns-44.net',
hostmaster: 'awsdns-hostmaster.amazon.com',
serial: 1,
refresh: 7200,
retry: 900,
expire: 1209600,
minttl: 86400
}
Note: The above program will compile and run by using the node index.js
command.
Reference: https://nodejs.org/api/dns.html#dns_dnspromises_resolvesoa_hostname
Share your thoughts in the comments
Please Login to comment...