get url args javascript code example
Example 1: get params js
// www.example.com/users?token=12345
let params = (new URL(document.location)).searchParams;
let token = params.get("token");
// 12345
Example 2: get data from url javascript
let url = 'https://www.example.com?name=n1&name=n2';
let params = (new URL(url)).searchParams;
params.get('name') // "n1"
params.getAll('name') // ["n1", "n2"]