diff --git a/doc/api/url.md b/doc/api/url.md index 843c4b544681ff..2c12e9ac29352f 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`][].