Answers for "how to get url parameters in typescript"

2

typescript read url parameters

// get all search params (including ?)
const queryString = window.location.search;
// it will look like this: ?product=shirt&color=blue&newuser&size=m

// parse the query string's paramters
const urlParams = new URLSearchParams(queryString);

// To get a parameter simply write something like the follwing
const paramValue = urlParams.get('yourParam');
Posted by: Guest on June-04-2021
-1

typescript read url search params

const product = urlParams.get('product')
console.log(product);
// shirt

const color = urlParams.get('color')
console.log(color);
// blue

const newUser = urlParams.get('newuser')
console.log(newUser);
// empty string
Posted by: Guest on January-28-2021

Code answers related to "how to get url parameters in typescript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language