The urlObject.href API is used to return the complete URL string along with the protocols(HTTP) and pathname or other search terms.
For example: 'http://www.geeksforgeeks.com/login/password.html' Here, Protocol = http Path = /login Host = 'www' File Name = password.html
Below programs illustrates the use of urlObejct.href method in Node.js:
Note: The above program will compile and run by using the node app.js command.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.