![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 – dns.resolveNs() Method
The dns.resolveNs() method uses the DNS protocol to resolve the nameserver records (NS Records) for the hostname. The addresses argument passed to the callback function will contain an array of nameserver records for the hostname.
Syntax
dns.resolveNs(hostname, callback)
Parameters
The above parameters are defined as below −
hostname – This parameter takes input for the hostname to be resolved.
callback – This function will catch errors, if any.
records – Returns the nameserver (NS) records for the hostname.
Example 1
Create a file "resolveNs.js" and copy the following code snippet. After creating the file, use the command "node resolveNs.js" to run this code:
// dns.resolveNs() Demo Example // Importing the dns module const dns = require('dns'); // Passing the argument below dns.resolveNs('tutorialspoint.com', (err,records) => console.log('NS Records: %j', records));
Output
NS Records: undefined
Example 2
// dns.resolveNs() Demo Example // Importing the dns module const dns = require('dns'); // Passing the argument below dns.resolveNs('google.com', (err,records) => console.log('NS Records: %j', records));
Output
NS Records: undefined
Advertisements