DEV Community

Cover image for node js express error (node:16508) UnhandledPromiseRejectionWarning: TypeError: Cannot read property(solution)
Osman Forhad
Osman Forhad

Posted on • Edited on

node js express error (node:16508) UnhandledPromiseRejectionWarning: TypeError: Cannot read property(solution)

trying to working with insert data into MongoDB and it was tasted by the POST Man testing tool but it shows me the below error:
(node:16508) UnhandledPromiseRejectionWarning: TypeError: Cannot read property
at this time I was not sure why this has happened then I was trying to search to find out it after a couple of time I find what was my mistake. the mistake I did which is I did not import middleware in my index file. so to solve this I goto this index.js file and import middleware there which is like below:
Alt Text
after importing this now everything is okay.
now my postman is like below:
Alt Text
.
that's it.
.
Happy Coding.
osman forhad
Mobile & Web Application Developer💻

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay