![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.resolveNaptr() Method
The dns.resolveNaptr() method uses the DNS protocol to resolve regular expression based words (NAPTR records) for the hostname. The addresses argument passed to the callback function will contain an array of objects with the following properties −
flags
service
regexp
replacement
order
preference
Syntax
dns.resolveNaptr(hostname, callback)
Parameters
hostname – This parameter takes input for the hostname to be resolved.
callback – This function will catch errors, if any.
Records – Returns NAPTR records for the hostname.
Example 1
Create a file "resolveNaptr.js" and copy the following code snippet. After creating the file, use the command "node resolveNaptr.js" to run this code.
// dns.resolveNaptr() Demo Example // Importing the dns module const dns = require('dns'); // Passing the argument below dns.resolveNaptr('tutorialspoint.com', (err, records) => console.log('NAPTR Records: %j', records));
Output
QueryReqWrap { bindingName: 'queryNaptr', callback: [Function], hostname: 'tutorialspoint.com', oncomplete: [Function: onresolve], ttl: false, channel: ChannelWrap {} } NAPTR Records: undefined
Example 2
// dns.resolveNaptr() Demo Example // Importing the dns module const dns = require('dns'); // Passing the argument below dns.resolveNaptr('google.com', (err, records) => console.log('NAPTR Records: %j', records));
Output
NAPTR Records: undefined
Advertisements