diff options
-rw-r--r-- | doc/api/url.md | 14 |
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`][]. |