![Full-Stack React Projects](https://wfqqreader-1252317822.image.myqcloud.com/cover/866/36699866/b_36699866.jpg)
上QQ阅读APP看书,第一时间看更新
Reading
The API endpoint to read a single user's data is declared in the following route.
mern-skeleton/server/routes/user.routes.js:
router.route('/api/users/:userId').get(userCtrl.read)
When the Express app gets a GET request at '/api/users/:userId', it executes the userByID controller function to load the user by the userId value in the param, and then the read controller function.
mern-skeleton/server/controllers/user.controller.js:
const read = (req, res) => {
req.profile.hashed_password = undefined
req.profile.salt = undefined
return res.json(req.profile)
}
The read function retrieves the user details from req.profile and removes sensitive information, such as the hashed_password and salt values, before sending the user object in the response to the requesting client.