doc: fix confusing example in dns.md
Currently, the example throws 'Error: getHostByAddr ENOTFOUND' The previous example is edited for consistency. PR-URL: https://github.com/nodejs/node/pull/11022 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
89e40c1ef3
commit
110b7cf2e4
@ -10,12 +10,12 @@ This category contains only one function: [`dns.lookup()`][]. **Developers
|
|||||||
looking to perform name resolution in the same way that other applications on
|
looking to perform name resolution in the same way that other applications on
|
||||||
the same operating system behave should use [`dns.lookup()`][].**
|
the same operating system behave should use [`dns.lookup()`][].**
|
||||||
|
|
||||||
For example, looking up `nodejs.org`.
|
For example, looking up `iana.org`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
|
|
||||||
dns.lookup('nodejs.org', (err, addresses, family) => {
|
dns.lookup('iana.org', (err, addresses, family) => {
|
||||||
console.log('addresses:', addresses);
|
console.log('addresses:', addresses);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@ -28,13 +28,13 @@ functions do not use the same set of configuration files used by
|
|||||||
developers who do not want to use the underlying operating system's facilities
|
developers who do not want to use the underlying operating system's facilities
|
||||||
for name resolution, and instead want to _always_ perform DNS queries.
|
for name resolution, and instead want to _always_ perform DNS queries.
|
||||||
|
|
||||||
Below is an example that resolves `'nodejs.org'` then reverse resolves the IP
|
Below is an example that resolves `'archive.org'` then reverse resolves the IP
|
||||||
addresses that are returned.
|
addresses that are returned.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
|
|
||||||
dns.resolve4('nodejs.org', (err, addresses) => {
|
dns.resolve4('archive.org', (err, addresses) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
console.log(`addresses: ${JSON.stringify(addresses)}`);
|
console.log(`addresses: ${JSON.stringify(addresses)}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user