Skip to content

Commit

Permalink
doc: dns examples implied string args were arrays
Browse files Browse the repository at this point in the history
Fix: #11334
PR-URL: #11350
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
sam-github authored and MylesBorins committed Mar 9, 2017
1 parent d1a8588 commit 0c9ea4f
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions doc/api/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ For example, looking up `nodejs.org`.
```js
const dns = require('dns');

dns.lookup('nodejs.org', (err, addresses, family) => {
console.log('addresses:', addresses);
dns.lookup('nodejs.org', (err, address, family) => {
console.log('address: %j family: IPv%s', address, family);
});
// address: "192.0.43.8" family: IPv4
```

2) Functions that connect to an actual DNS server to perform name resolution,
Expand Down Expand Up @@ -115,6 +116,25 @@ important consequences on the behavior of any Node.js program. Please take some
time to consult the [Implementation considerations section][] before using
`dns.lookup()`.

Example usage:

```js
const dns = require('dns');
const options = {
family: 6,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};
dns.lookup('example.com', options, (err, address, family) =>
console.log('address: %j family: IPv%s', address, family));
// address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6

// When options.all is true, the result will be an Array.
options.all = true;
dns.lookup('example.com', options, (err, addresses) =>
console.log('addresses: %j', addresses));
// addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
```

### Supported getaddrinfo flags

The following flags can be passed as hints to [`dns.lookup()`][].
Expand Down

0 comments on commit 0c9ea4f

Please sign in to comment.