Node.js urlObject.search API Last Updated : 14 Oct, 2021 Improve Improve Like Article Like Save Share Report The urlObject.search() method in Node is used to get the search query within the hostname which is followed by the ‘?’ character. Syntax : urlObject.search() Return : Returns the search query after ‘?’ character. Example #1 : In these examples, we have shown how the urlObject.search() method is able to extract the search query from the hostname. // Importing the module 'url' const url = require('url'); var adr = 'http://localhost:8080/default.htm?year=2019&month=may'; // Parse the address: var q = url.parse(adr, true); /* The parse method returns an object containing URL properties */ console.log(q.search); Output : Example #2 : // Importing the module 'url' const url = require('url'); var adr = 'http://localhost:8080/default.htm?year=2k19&month=geekofthemonth'; // Parse the address: var q = url.parse(adr, true); /* The parse method returns an object containing URL properties */ console.log(q.search); Output : Like Article Suggest improvement Previous Node.js urlObject.host API Next Node.js urlObject.protocol API Share your thoughts in the comments Add Your Comment Please Login to comment...