Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
