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

385
Vistas
How to add url params to a static url?

I have this address 'http://www.example.com' I want to add 'fileName=samplefile' url parameter to my static url (http://www.example.com).

const myUrl = new URL('https://example.com);

myUrl.searchParams.append('fileName', 'samplefile');

I tried this approach and that didn't work.

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

0

Just change the string in the first line and add the URL parameters as specified in the http querystring definition.

const myUrl = new URL('https.//example.com?fileName=samplefile');
console.log(myUrl.search);

Check out the specification of URL as well, to learn more about that.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use a combination of two methods: URL & URLSearchParams

Example:

var url = new URL("https://example.com");

// If you expected result like this "http://example.com/?fileName=samplefile"
url.searchParams.append('fileName','samplefile');
console.log(url.href);//"http://example.com/?fileName=samplefile"

You can use url.href to get the full URL

You could also use URLSearchParams

let url = new URL("https://example.com");

const urlParams = new URLSearchParams();
urlParams.set('fileName', 'samplefile');

url.search = urlParams;
console.log(url.href);//"http://example.com/?fileName=samplefile"
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