summaryrefslogtreecommitdiff
path: root/doc/api/url.md
diff options
context:
space:
mode:
authorZeke Sikelianos <zeke@sikelianos.com>2018-02-20 12:10:54 -0800
committerAnatoli Papirovski <apapirovski@mac.com>2018-03-04 12:47:55 +0100
commit1572a5b6cd16aeb6cafd338814ead76c0f198f1d (patch)
tree80221f14cd9b1655069e70ba57eebb2db8419269 /doc/api/url.md
parenta865e8ba6781a7d3640df1c8cc1ce493fef7231b (diff)
downloadandroid-node-v8-1572a5b6cd16aeb6cafd338814ead76c0f198f1d.tar.gz
android-node-v8-1572a5b6cd16aeb6cafd338814ead76c0f198f1d.tar.bz2
android-node-v8-1572a5b6cd16aeb6cafd338814ead76c0f198f1d.zip
doc: add URL.format() example
PR-URL: https://github.com/nodejs/node/pull/18888 Fixes: https://github.com/nodejs/node/issues/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>
Diffstat (limited to 'doc/api/url.md')
-rw-r--r--doc/api/url.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/api/url.md b/doc/api/url.md
index 843c4b5446..2c12e9ac29 100644
--- a/doc/api/url.md
+++ b/doc/api/url.md
@@ -948,6 +948,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`][].