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

150
Visualizações
Making the client able to receive custom parameters from a URL using Express/NodeJS

I am trying to create a nodeJS/Express site where users are able to create posts. Each post has its own id (consisted of 6 random characters). I want to make it so that when a user enters the URL http://localhost:3000/post/123456/, the user sees HTML on their screen but the id of the post they're trying to see, that means the second parameter in the URL (In this case, 123456) is given to the client.

For example, if the user goes on http://localhost:3000/post/111111/, I want the client to see HTML, but, I want the Javascript on that page to receive that id (111111), either in a variable or in a cookie.

I've tried using express app.get, like this:

app.get("/post/:id", (req, res) => {
    req.send(req.params.id)
})

But, obviously that didn't work, since that doesn't send back HTML, but instead sends back a string. Is there any way of doing that, or at least something similar to that?

about 4 years ago · Juan Pablo Isaza
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