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

187
Views
Trying to send more than one parameter to a GET function

I am trying to send more than one parameter to the GET function. Right now I have:

const response = await fetch(`http://localhost:5000/demos/price/${numticket}/${carry}`);

And I am trying to send this information to (but the request does not go to the function):

app.get('/demos/price/:ticket/:carry', async(req, res)=>{
  //console.log('in index');
  try{
      let ticket = req.params.ticket;
      let carry = req.params.carry;
  } catch(err){
    console.log(err.message);
  }
});

Is this how I go about doing this or do I have it completely wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're capturing path parameters correctly, except you don't need the try/catch block around setting variables since you're not doing anything that can throw an error. This works as expected for me:

app.get('/demos/price/:ticket/:carry', (req, res)=>{;
  res.send(req.params.ticket + ' ' + req.params.carry)
});

(Sent request in my terminal via curl like so: curl localhost:3000/demos/price/aaa/bbb, but the way you're sending it in JS is correct as well)

Is it possible that it's working properly but you're just not noticing anything happening because you're just setting variables and not logging anything or returning a response?

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!