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

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

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