Home › Node.js Tutorial › Node.js URL and query strings
Node.js URL and query strings
Pick apart web addresses.
The URL class splits an address into parts. searchParams.get reads a value from the query string.
Example code
const u = new URL("https://example.com/shop?item=pen&qty=3");
console.log(u.hostname);
console.log(u.searchParams.get("qty"));