Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Using Object.keys() to get searchParams

Considering the below:

const [searchParams, setSearchParams] = useSearchParams();

  console.log(searchParams.toString());

  console.log(typeof searchParams);

  console.log(Object.values(searchParams));

And passing the URL http://localhost:3000/client-data?task=test

This logs:

task=test (The string of the object, understandable)

object (We know it's of type object, and has some key value pairs from prior test)

[] (Why are we not getting any keys / values from Object.keys() etc?)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Why are we not getting any keys / values from Object.keys() etc?

The key/values of the search params are not exposed as own properties of the object instance. They cannot be. Consider the following

const params = new URLSearchParams("a=1&get=2");

console.log(params.a);
console.log(params.get);

console.log(params.get("a"));
console.log(params.get("get"));

If params.a gave you the value "1", then params.get should also give you "2". Yet that means it would overwrite the .get() method. And if that were to happen, then params.get("a") would never work.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda