Skip to content

Commit 1572a5b

Browse files
zekeapapirovski
authored andcommitted
doc: add URL.format() example
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]>
1 parent a865e8b commit 1572a5b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/api/url.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,20 @@ changes:
948948
The `url.format()` method returns a formatted URL string derived from
949949
`urlObject`.
950950

951+
```js
952+
url.format({
953+
protocol: 'https',
954+
hostname: 'example.com',
955+
pathname: '/some/path',
956+
query: {
957+
page: 1,
958+
format: 'json'
959+
}
960+
});
961+
962+
// => 'https://example.com/some/path?page=1&format=json'
963+
```
964+
951965
If `urlObject` is not an object or a string, `url.format()` will throw a
952966
[`TypeError`][].
953967

0 commit comments

Comments
 (0)