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

106
Vistas
URL parameter starting zero is removed

I have the URL: http://localhost:3000/homebrew/board?id=078262

I use node to get the id parameter and store it into a variable. When the page gets loaded, I use the variable with EJS to pass it to the client.

The issue is that if an id starts with zero 0, it gets removed.

App.JS

app.get('/homebrew/:homebrewType', (req, res) => {

  var type = req.params.homebrewType;
  var homebrewId = req.query.id;

  console.log(homebrewId); // shows 078262
  console.log(typeof homebrewId); // string

...

  res.render('pages/homebrew-' + type, {
    homebrewId: homebrewId
  });

JS

var viewingHomebrew = <%= homebrewId %>;

console.log(viewingHomebrew); // shows 78262, starting 0 is missing

I don't have any other code, how can I preserve the id parameter?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to add quotes to make it a string instead of a number.

var viewingHomebrew = "<%= homebrewId %>";
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