Skip to content
Advertisement

Tag: mongodb

“TypeError: Cannot read properties of undefined (reading ‘hasOwnProperty’)” error

EDIT: PROBLEM SOLVED. I’m trying to make an update profile page for an Express app with Mongoose, and I got the error “TypeError: Cannot read properties of undefined (reading ‘hasOwnProperty’)”. I am confused how to fix it. Here is my code, thanks (error shown) [1]: https://i.stack.imgur.com/xss8j.png Answer So… idk why this works but I forgot to make the profile picture

JSON empty when is called from another file

I’m learning NodeJS and MongoDB. I dont know what is happening with this function. If I make a console.log before return user, it works fine (just print an JSON array with all info of the collection) The problem is when I call it from another file (in my case, the router). If I do this, I receive an empty json.

MongoDb query return empty object

I’m trying to perform a simple .find() query on my mongodbAtlas, but the result of this query is an empty object. this is my server file: this is my routes file: this is how my document is populated: Answer I think you are missing the “await” keyword after const data….. as API data fetching calls are asynchronous and required promise/

Advertisement