![]() |
The URL.format(urlObject) is the inbuilt API provided by URL class, which takes an object or string and return a formatted string derived from that object or string. Syntax: const url.format(urlObject) If the urlObject is not an object or string, then it will throw a TypeError. The urlObject can have the following fields or keys:
The formatting process is as follows:
2. urlObject.protocol: string
Example 1
Output: https://example.com:1800/sample/path?page=1&format=json#first Example 2
Output: prct:[email protected]/sample/path?something#first NOTE: The above program will compile and run by using the node fileName.js command. Reference: |
Reffered: https://www.geeksforgeeks.org
Node.js |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |