I'm testing an API on Postman. When the user logins, I sent a JWT as the response.
The payload consists of the UserID from the database.
const token = jwt.sign(
{
_id: user._id,
},
"jwtPrivateKey"
);
return res.status(200).json({ message: "Login Successful!", token: token });
Next when the user wants to fetch some data, I want to know which user is trying to fetch it.
How can I do that?