Anbody working with MERN? I have error.
ivkeMilioner

ivkeMilioner @ivkemilioner

Location:
Beograd
Joined:
Oct 15, 2019

Anbody working with MERN? I have error.

Publish Date: Dec 28 '21
2 12

I have a problem with reading data from mongo. I can't find the problem. I get an empty array from mongo.

https://github.com/dragoslavIvkovic/MERN-WOLT/tree/master

Comments 12 total

  • Mainak Das
    Mainak DasDec 28, 2021

    Elaborate ?
    Add help as tag also

    • ivkeMilioner
      ivkeMilionerDec 28, 2021

      That is problem. I can't find where is problem. I getiing empty array from mongo database. In this file I geting only "Loading"
      github.com/dragoslavIvkovic/MERN-W...

      • Mainak Das
        Mainak DasDec 29, 2021

        I tried to git clone the repo and starting to debug but found mongo connect error/ timeout? Will that be the problem? I'm guessing not. Can you remove the IP restrictions (if any) so that I can debug further? :D

        • ivkeMilioner
          ivkeMilionerDec 29, 2021

          I removed IP restriction

          • Mainak Das
            Mainak DasDec 29, 2021

            I checked the logs, the thing you were doing was not connecting the DB to the running server. As a result DB is running its own and server in its own. Second thing you need to add CORS to enable API access from other domains.

            Tried to push the updated code, but blocked.

            • ivkeMilioner
              ivkeMilionerDec 29, 2021

              Thank you to heaven for spanindg your time on me. Thank you to heaven for wasting your time on me. Can you email me an update?

              • Mainak Das
                Mainak DasDec 29, 2021

                No worries man ;) debugging is always good
                Also I checked your DB, there are two tables food and foods. The Food.find({}) is accessing the food table. You may have to check that to get the required values from the correct table i.e foods.

                Can you ping me at mainakdas104@gmail.com 😊

  • Jared Long
    Jared Long Dec 29, 2021

    What’s getting logged from the console log in your ‘foodAction.js’?

    • Jared Long
      Jared Long Dec 29, 2021

      It could potentially be related to your action dispatching GET_FOODS_REQUEST, which sets loading to true but that dispatch doesn’t contain any new state. I wonder if your try/catch is being ran

  • Humberto David Esquerra
    Humberto David EsquerraDec 29, 2021

    My advice would be to checkout w3schools use of mondgodb. They don't use mongoose they use the official mongodb npm driver. Also try to keep everything in your database.js file and add function arguments to fetch specific collection documents by name. My last advice would be make sure the data your sending to client is a resolved promise. If it isn't a resolved promise your gonna need another call back to resolve the data in the frontend. Good luck! Hang in there!

Add comment