Skip to content

Commit

Permalink
doc: add URL.format() example
Browse files Browse the repository at this point in the history
PR-URL: nodejs#18888
Fixes: nodejs#18887
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
zeke authored and addaleax committed Mar 5, 2018
1 parent d883376 commit cab6c8e
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 cab6c8e

Please sign in to comment.