Hey guys,I have been working for a short time with JavaScript and Node, building APIs with Express is completely new to me.I started to use ESLint to improve my code, but at one point I can not fix the error ESLint is throwing:"Assignment to property of function parameter 'req'. (no-param-reassign)"function verifyToken(req, res, next) { const token = req.headers.authorization; if (typeof token !== 'undefined') { req.token = token; next(); } else { res.sendStatus(403); } } How should I write my verify-function which assigns the token to the request, that I can verify the token itself in the next function?Thank you
Submitted April 20, 2018 at 05:36PM by Freddyan
No comments:
Post a Comment