Hey I'm making reset password route (EXPRESSJS) and I have a problem. My route looks like this: /reset-password/:resetToken.
And I get it like that: const token = req.params.resetToken
When I console.log that variable it logs it without any errors but when I try to check if it is in db it return as undefined
Some code:
AuthRouter.put("/reset-password/:resetToken", async (req, res) => {
const token = req.params.resetToken
try {
console.log(token);
const getResetToken = await pool.query("SELECT * FROM users WHERE user_password_reset_token = $1", [
token
])
Try add `` instead of " in query
`SELECT * FROM users WHERE user_password_reset_token = $1`
Hey you can try this one, It will work on dynamic values:
const getResetToken = await pool.query(
`SELECT * FROM users WHERE user_password_reset_token = $1`,
[token]
)