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

101
Views
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 answers
Answer question

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