DEV Community

Discussion on: Authentication in NodeJS With Express and Mongo - CodeLab #1

Collapse
 
josecage profile image
José Cage

Thank you so much for your article. Really helped me.

I just faced a error with auth middleware:

TypeError: Cannot read property 'header' of undefined
Enter fullscreen mode Exit fullscreen mode

The error comes from

const token = req.header('token');
Enter fullscreen mode Exit fullscreen mode
Collapse
 
iuu profile image
iu-u

Did you manage to fix this? getting same error

Collapse
 
mikeypenny profile image
Miguel Sandoval

If you are using x-www-form-urlencoded you can get the params with req.body
Same is you send a json object from raw instead of x-www-form-urlencoded