Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

386
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!