Node | URLSearchParams.get()
In URLSearchParams interface, the get() method returns the first value of the input search parameter.
Syntax:
URLSearchParams.get(name)
Returns:The string will be returned if the name-value pair is found, else null will be returned.
Parameters:
name – Input the name of the parameter.
Example1: When input parameter is present
var URL = require('url').URL; let params = new URLSearchParams(url.search.substring(1)); let name = params.get("name"); // is the string "Deepak" let age = parseInt(params.get("age"), 10); // is the number 20 console.log(name) console.log(age) |
chevron_right
filter_none
Output:
Deepak 20
Example2: When input parameter is not present
var URL = require('url').URL; let params = new URLSearchParams(url.search.substring(1)); let address = params.get("address"); console.log(address) |
chevron_right
filter_none
Output:
null
Supported Browsers:
- Google Chrome
- IE
- Edge
- Opera
- Apple Safari
Recommended Posts:
- Node.js | NPM (Node Package Manager)
- PHP vs. Node.js
- Node js | OS
- Why Node.js ?
- Node | URL.port API
- Node.js | pop() function
- Node | URL.format API
- Node | URL.password API
- Node | URL.hostname API
- Node | URL.href API
- Node | URL.pathname API
- Node | URL.username API
- Node | URL.search API
- Node | URL.origin API
- Node.js Events
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



