![]() |
VOOZH | about |
The url.host is an inbuilt application programming interface of class URL with in url module which is used to get and set the host portion of the URL.
Syntax:
const url.host
Return value: It gets and sets the host portion of the URL.
Below programs illustrates the use of url.host Method:
Example 1:
Output:
Before Change https://example.com:80/foo#ram After Change https://example.com:82/foo#ram
Example 2:
Output:
example.org:82
NOTE: The above program will compile and run by using the node myapp.js command .
Reference:
https://nodejs.org/dist/latest-v10.x/docs/api/url.html#url_url_host