Skip to content

Commit

Permalink
doc: add URL.format() example
Browse files Browse the repository at this point in the history
Backport-PR-URL: #22380
PR-URL: #18888
Fixes: #18887
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
zeke authored and MylesBorins committed Sep 6, 2018
1 parent c2978ac commit d9895c4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,20 @@ changes:
The `url.format()` method returns a formatted URL string derived from
`urlObject`.

```js
url.format({
protocol: 'https',
hostname: 'example.com',
pathname: '/some/path',
query: {
page: 1,
format: 'json'
}
});

// => 'https://example.com/some/path?page=1&format=json'
```

If `urlObject` is not an object or a string, `url.format()` will throw a
[`TypeError`][].

Expand Down

0 comments on commit d9895c4

Please sign in to comment.