I have a middleware which attaches a UserId to the request object.(similar to the explanation in https://stackoverflow.com/questions/12518132/modifying-express-js-request-object) It functions properly while using the application. But while running frisby the request object is not getting modified.
Following is the middleware I used:
exports.appendUserId = () => {
return (req, res, next) => {
try {
req.body.UserId = this.authenticatedUsers.tokenMap[utils.jwtFrom(req)].data.id
console.log("UserId:", this.authenticatedUsers.tokenMap[utils.jwtFrom(req)].data.id)
console.log("req.body.UserId:", req.body.UserId)
req.body.UserId = 1
console.log("req.body.UserId:", req.body.UserId)
next()
} catch (error) {
res.status(401).json({ status: 'error', message: error })
}
}
}
Expected Terminal Output:
UserId: 2
req.body.UserId: 2
req.body.UserId: 1
Present Terminal Output:
UserId: 2
req.body.UserId: undefined
req.body.UserId: undefined
I have a middleware which attaches a UserId to the request object.(similar to the explanation in https://stackoverflow.com/questions/12518132/modifying-express-js-request-object) It functions properly while using the application. But while running frisby the request object is not getting modified.
Following is the middleware I used:
Expected Terminal Output:
Present Terminal Output: