DEV Community

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

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

osmanforhad profile image Osman Forhad ・1 min read

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💻

Discussion (0)

pic
Editor guide