Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

383
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda