A Fool learning ~

Renan Aguiar

Parse query params

If you are learning express just like me, take a look at this.

if (req.params.id === userFromDB.id) {
  console.log("Same") // never going to run
} else {
  console.log("Different")
}

The first conditional will never happen. Why? You might ask. Because everything from query params always comes as strings, while your user id will be a number. The solution is to simply parse it.

if (parseInt(req.params.id, 10) === userFromDB.id) {
  console.log("Same")
} else {
  console.log("Diferent")
}