Skip to content

Commit cab6c8e

Browse files
zekeaddaleax
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 d883376 commit cab6c8e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/api/url.md

+14
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,20 @@ changes:
971971
The `url.format()` method returns a formatted URL string derived from
972972
`urlObject`.
973973

974+
```js
975+
url.format({
976+
protocol: 'https',
977+
hostname: 'example.com',
978+
pathname: '/some/path',
979+
query: {
980+
page: 1,
981+
format: 'json'
982+
}
983+
});
984+
985+
// => 'https://example.com/some/path?page=1&format=json'
986+
```
987+
974988
If `urlObject` is not an object or a string, `url.format()` will throw a
975989
[`TypeError`][].
976990

0 commit comments

Comments
 (0)