Jarko
Jarko

Reputation: 81

UnhandledPromiseRejectionWarning: TypeError Cannot read property 'name' of undefined

i am trying to create user login and registration using node express and mongoose... created the User Model....trying now to add a post method in my router auth.js but for some reason i keep getting the error Cannot read property 'name' of undefined yesterday i wrote exactly the same code, but with some other post methods and it went perfectly fine....

i just want the post to work on postman for now that's it...thanks alot

auth.js file

User.js File

enter image description here

Upvotes: 1

Views: 4724

Answers (1)

Jarko
Jarko

Reputation: 81

it turned out that the order of the middleware counts here...i just moved the app.use(express.json()) before the routes add ,,,,and it went fine....thanks Subburaj...appreciate your help :)

Upvotes: 5

Related Questions