Deployed site on Render not retrieving data from MongoDB

20 Views Asked by At

I'm currently working on part 3c, Saving Data to MongoDB. My phonebook app is able to fetch data from the MongoDB database while on the local server in development mode, but not while on the Render server. Instead of an array of the person objects, it returns just an empty array. It works fine fetching all the persons from '/api/persons' on the local server.

the person's.js file that connects to the database The index.js file where it is used

I put log statements in the persons.js and the index.js files to see what the Person object is and the persons object returned from MongoDB which is shown on the Render logs. the logs from the Render console

What could I be doing wrong?

1

There are 1 best solutions below

0
HassanShakur On

The code looks fine. The only thing I can think of is that you are using 2 different databases - a local and a hosted one. The local has some data, while the one accessed by render is empty.