Questions tagged [urlsearchparams]

65 questions
0
votes
0 answers

Cannot access url.searchParams Prerendering - SvelteKit

I would like to make specific link from my page ( https://www.bizraport.pl/organizacje ) prerendered. My issue is that page uses (in both +page.server.js and +page.svelte) url.searchParams.get which makes an error: Error: Cannot access…
0
votes
0 answers

URL Query Params returns [object%20Object]

I used URLSearchParams() to extract data from my query parameters My query param looks like this /?dt=Sample&ut=Sample%20Data ContractView.tsx import React, { ReactElement, useEffect, useState } from 'react' import Viewer from…
0
votes
0 answers

Where is this Query parameter psafe_param coming from?

We are running a WP website and we see that on some linke a query parameter is added? https://example.com/?psafe_param=1glcid={some long hash string} We have no clue where it is coming from? We searched everywhere in WP for this but can not find the…
eaonflux
  • 9
  • 1
0
votes
1 answer

Finding a key by its value in JavaScript returns undefined

I am trying to delete a key and a value that I got using useSearchParams() hook in React Router v6 by clicking "remove" button on a filtered value. I need to find a key by its value, so I coded as follows but it returns "undefined" key in console. I…
Yuko
  • 31
  • 8
0
votes
0 answers

react const useSearchParams not list all keys

const [search_par, set_search_par] = useSearchParams(); for (const p of search_par.keys()) { if (!["tab", "context"].includes(p)) { search_par.delete(p); } } This for loop will only go up to 4 keys even when the url has more.…
0
votes
0 answers

How do I handle commas in array of strings when using URLSearchParams()

I am sending an AJAX request to my backend application using the following code: function add() { ajax('add', 'POST', { content: ['abc', 'xyz,123'] }); } function ajax(endpoint, method, payload, callback) { const xhttp = new…
gib65
  • 1,709
  • 3
  • 24
  • 58
0
votes
0 answers

Routers with query params

When I am trying to console query params I am getting empty object and my URL is http://localhost:3000/searchResult?Empid=220. My code to set and get the query params is shown here. Using params I need to filter my Emp object and need to display the…
Diyan
  • 1
  • 2
0
votes
1 answer

Why the url first parameter is not being considered in Javascript?

const url = new URLSearchParams('https://example.com?q1=1&q2=2'); console.log(url.has('q3')) // returns false as expected console.log(url.has('q2')) // returns true as expected console.log(url.has('q1')) // returns false as NOT expected Why it…
kodfire
  • 1,612
  • 3
  • 18
  • 57
0
votes
1 answer

why does the URLSearchParams iterator skip every other k,v pair

Consider the following simple function with a URLSearchParams iterator. const foo = (qs) => { const sp = new URLSearchParams(qs); console.log(`pre: ${sp}`); for (const [key, val] of sp.entries()) { console.log(`'${key}:…
punkish
  • 13,598
  • 26
  • 66
  • 101
0
votes
0 answers

Is it possible to use dynamic types base on URLSearchParams value in typescript

is it possible change my type dynamically based on a function call, like the URLSearchParams has? here's what i am triyng to: interface X { get: (Uparams?: URLSearchParams) => Promise< Uparams.has('page') extends true ? T[] :…
Neto Braghetto
  • 1,371
  • 1
  • 15
  • 30
0
votes
2 answers

urlSearchParams not updating the url

I am trying to add search and page to my url for searching and pagination on a page. const urlParams = new URLSearchParams(window.location.search); if(!urlParams.has('search'){ urlParams.append('search', question); } if(!urlParams.has('page'){ …
andrelange91
  • 1,018
  • 3
  • 21
  • 48
0
votes
1 answer

Convert multilevel object to query string

How i can convert object into location%5Bokrug%5D%5B%5D=38&location%5Bokrug%5D%5B%5D=41: let filter = { location: { okrug: [38, 41] } } URLSearchParams does not help: console.log(new URLSearchParams(filter).toString()) //got…
osipovmn
  • 1
  • 1
0
votes
0 answers

Google App Scripts ReferenceError: URLSearchParams is not defined

I am trying to access an API in an apps scripts function. I have tested my code in VS code and it works just fine, but when I run it in apps scripts, I get an error saying "ReferenceError: URLSearchParams is not defined". Does anyone know of a fix?…
0
votes
1 answer

there's no question mark printing before query params

first way I tried is : static async callSendApi(requestBody) { let url = new URL( `${API_URL}/${PAGE_ID}/messages` ); url.search = new URLSearchParams({ access_token: `${PAGE_ACCESS_TOKEN}`, }); …
0
votes
0 answers

I get unknown path components: in messenger api

My api is as follows.. const { URL, URLSearchParams } = require("url"); async callSendApi(requestBody) { let url = new URL(`${API_URL}/${PAGE_ID}/messages`); url.search = new URLSearchParams({ access_token: `${PAGE_ACCESS_TOKEN}`, …
Imangi
  • 43
  • 2
  • 7