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

190
Vistas
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 Respuestas
Responde la pregunta

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 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