Message from JavaScript discussions

October 2020

— Call Gabe Newell

— 

Exports.reset_password = async (req, res) => {
try {
const { token } = req.params
if (!token) {
return res.status(404).json({
status: 'error',
message: 'Link not provided or Link has expired'
})
}
const verifyToken = jwt.verify(token, TOKEN_SECRET)
if (!verifyToken) {
return res.status(401).json({
status: 'error',
message: 'Authorization failed'
})
}
const user = await User.findOne({
where: {
resetToken: verifyToken
}
})
if (!user) {
return res.status(401).json({
status: 'error',
message: 'User not found'
})
}
const updatePassword = await bcrypt.hash(req.body.password, 10)
await user.update({
password: updatePassword,
resetToken: null
}, {
where: {
password: user.password,
resetToken: user.resetToken
}
})
return res.status(201).json({
status: 'success',
message: 'You have successfully updated your password.'
})
} catch (error) {
return res.status(500).json({
status: 'error',
message: error.message
})
}
};


What is it I'm doing wrong?
When I send the request, I don't get any errors or response. It just keeps on loading

— Which web framework do you use? Express, Fastify or smth else?

— Express

— Everything seems to be okay with the code. Show api endpoins declarations please.

— There might be a mistake in importing or might've not called the function.

— The last time i had something like that - page keeps reloading - was when the request was not ending (there was no return res.XXX)

Message permanent page

— I'd also check if there is a missing return xyz somewhere

— But I returned in the code I pasted 😭

— I did that's why it keeps on loading

— If I didn't it won't connect at all

— Send the code where you declared the api endpoints.