![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js – dnsPromises.resolveAny() Method
The dnsPromises.resolveAny() method uses the DNS protocol to resolve all records (this is also known as ANY or * query). The promise is resolved with an array containing various types of records.
Type | Properties |
---|---|
'A' | IPv4 address |
'AAAA' | IPv6 address |
'Any' | Any Records |
MX | Mail Exchange Records |
NAPTR | Name authority pointer records |
NS | Name server records |
PTR | Pointer Records |
SOA | Start of Authority Records |
SRV | Service Records |
TXT | Text Records |
CNAME | Canonical Name Records |
Syntax
dnsPromises.resolveAny(hostname)
Parameters
hostname - This parameter takes input for the hostname to be resolved.
Example 1
Create a file with the name "resolveAny.js" and copy the following code. After creating the file, use the command "node resolveAny.js" to run this code, as shown in the example below −
// Node.js program to demonstrate the // dnsPromises.resolveAny() method // Accessing promises object from dns module const dns = require('dns'); const dnsPromises = dns.promises; // Calling dnsPromises.resolveAny() method dnsPromises.resolveAny('tutorialspoint.com').then((response) => { console.log("records :", response); });
Output
C:\home
ode>> node resolveAny.js records: [ {"address":"95.217.74.146","ttl":600,"type":"A"}, {"exchange":"alt2.aspmx.l.google.com","priority":5,"type":"MX"}, {"exchange":"alt1.aspmx.l.google.com","priority":5,"type":"MX"}, {"exchange":"aspmx.l.google.com","priority":1,"type":"MX"}, {"exchange":"alt4.aspmx.l.google.com","priority":10,"type":"MX"}, {"exchange":"alt3.aspmx.l.google.com","priority":10,"type":"MX"}, {"value":"pdns13.domaincontrol.com","type":"NS"}, {"value":"pdns14.domaincontrol.com","type":"NS"}, {"entries":["google-site-verification=-RNrP1jBNMarh7tMQEgXtlBVUi000DUph-h8H7uSaQ"],"type":"TXT"}, {"entries":["google-siteverification=S2zMIBQyc6WxHPiOdUzkWYvx_FKbf03xDOsI8OgG20A"],"type" :"TXT"}, {"entries":["v=spf1 ip4:116.202.79.150 include:_spf.google.com - all"],"type":"TXT"}, {"nsname":"pdns13.domaincontrol.com","hostmaster":"dns.jomax.net" ,"serial":2021051700,"refresh":28800,"retry":7200,"expire":604800 ,"minttl":600,"type":"SOA"} ]
Example 2
// Node.js program to demonstrate the // dnsPromises.resolveAny() method // Accessing promises object from dns module const dns = require('dns'); const dnsPromises = dns.promises; // Calling dnsPromises.resolveAny() method dnsPromises.resolveAny('localhost').then((response) => { console.log("Address :", response); });
Output
C:\home
ode>> node resolveAny.js Address : [ { address: '127.0.0.1', ttl: 0, type: 'A' }, { address: '::1', ttl: 0, type: 'AAAA' } ]
Advertisements