Questions tagged [urlsearchparams]
65 questions
1
vote
0 answers
params.get("") is not working when i try to render a page with an id from a local dataset
I'm trying to create a page that renders information dynamically by drawing from a local dataset using params.get(""). While the URL is set, whatever parameter I put in params.get("") does not render on the page.
Here is the code for directing the…

Malik Awesu
- 11
- 1
1
vote
1 answer
window.history.pushState() does not work on URLSearchParams
Hi I am trying to pass params to backend from frontend using URLSearchParams to filter a list.
The filtering did not happen without reloading the page because URLSearchParams wasn't updated.
I wrote code as follows by searching the answers on this…

Yuko
- 31
- 8
1
vote
2 answers
how to check whether window.location.pathname ends with /search?
I am trying to track a page visit when someone lands on a search results page. Right now I have an isMatch function, and if it returns true, then it sends an event.
Is there a way to check against window.location.pathname, to basically check whether…

Schneider G
- 63
- 6
1
vote
1 answer
AWS cognito callback can't read url params
I'm using AWS cognito hosted UI , after signing in I get redirected to the callback URL I configured with the id_token in the url , the problem is that there's a '#' character before the idtoken ( http://exmple.com/callback#id_token=eyJra ) and this…

MrChaker Atallah
- 43
- 1
- 5
1
vote
1 answer
React How to use query string when using react-router-dom v6
I am currently building an e-commerce website with React, and I have question about query params.
In every e-commerce website, there are filters. I want to use useSearchParams for this filter (sort, conditions, min price, max price, categories,…

Youngjun Woo
- 39
- 8
1
vote
1 answer
URLSearchParams.set() without URIEncoding
URLSearchParams.set(key, value) URIEncodes the values its given, producing ugly non-specified urls.
The following test is based off this list of url friendly characters
const url = new URL("http://www.example.com/path");
const test =…

Seph Reed
- 8,797
- 11
- 60
- 125
1
vote
1 answer
Is it ok to use unencoded reserved characters in url?
I have a requirement of adding multiple nested paths in the querystring. For which, im encoding the individual path names and combine those with / (delimiter). If a path contains slash in it, that will be encoded as %2F..However we are not encoding…

saranya
- 9
- 2
1
vote
3 answers
Get array of objects from query params object
I have object with queryparams keys and values such as:
const params = {
'filter[0][key]': 'name',
'filter[0][operator]': 'like',
'filter[0][value]': 'test',
'filter[1][key]': 'age',
'filter[1][operator]': '=',
…

Иван Кожуховский
- 33
- 4
1
vote
1 answer
Create a query string in a URL (for a link )
I am trying to create a query string in a URL for a link. I can't find what is the problem, I tried a lot of thing but I always get an "undefined" for "urlCameras". thanks for your help !
const cameras = [{
_id: "Camera 1"
}];
const linkProduct…

Pauline Momot
- 39
- 4
1
vote
2 answers
JS - URLSearchParams - add parameters
I don't seem to be able to add parameters/queries to the URL. I'm trying to add parameters to the url. I'm trying to do it with .set() and .append() but neither seems to do what I thought it'd do. Am I misunderstanding what those methods are meant…

Wasteland
- 4,889
- 14
- 45
- 91
0
votes
1 answer
Cannot read properties of undefined (reading 'size') - Next js 13
Today, i come up with one problem that i'm using Next js 13.4 version with backend. so when i used searchParams in server side, it was throwing error: Cannot read properties of undefined (reading 'size') iam destructuring size and style search…

Raghunadh Hital
- 25
- 6
0
votes
2 answers
Encoding special characters whilst setting parameters on the URL
I need to set a number of URL parameters, which also need to include a special character $
Currently I am using .set() to create and set these parameter values:
const myUrl = new URL("http://www.example.com/?");
let params = new…

user1486133
- 1,309
- 3
- 19
- 37
0
votes
0 answers
How do I get the searchParams from the requested url in server side next js 13?
I am working on a multilingual next js 13 app with "app directory". I have a page like "/products", where I will be filtering the page data with URLSearchParams. I have created a client side component for filtering the data in a separate file. I am…

bishal dores
- 13
- 5
0
votes
2 answers
How do I delete a specific parameter from URL without deleting other parameters with the same key?
I've got this code working fine. But The delete() function deletes all entries with the key equal to "foo".
`let url = new URL("https://example.com?foo=1&bar=2");
let params = new URLSearchParams(url.search);
//Add a second foo parameter.
…
0
votes
0 answers
Next.js middleware gets different url from request then desired
I am developing a module for our web application. The user can access a module in the following way:
After the credentials were checked and they are correct the user is redirected to the requested URL. The URL has an acct query param which is a JWT…

Bátorfalvi Géza
- 11
- 3