Failing to Connect to mongoDb w/ Mongoose via Glitch

Tell us what’s happening:

sometimes for a brief minute i can pass some challanges however i never get the code saying its connected and i get other errors in the console which i cant follow. then i go back to the first challange and it fails again saying not connected to DB:
Here is link

i have whitelisted all ips
i have double checked the login username / password: testUser / admin123

strong text

Your code so far
console log errors such as:
(node:1417) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

1:49 PM

(node:1417) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0.

Challenge: undefined

Link to the challenge:
https://www.freecodecamp.org/learn/apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose

Are you behind a firewall?

So you are not able to passing the challenge you linked from Install and Setup Mongoose?

hi:)
thanks for reply. i really wanna keep learning!

i dont belive im behind a firewall however that didnt cross my mind so i will now try and confirm that 100%

i have manged to pass this challenge after randonly clicking for abit however i go back to it 5minutes later no changes to the code and again it doesnt pass. this leads me to belive it is connection issues rather than anything else.

Can you post a screenshot of which tests are failing and which shows the url you are submitting?

Hi, sorry for the slow reply life gets in the way sometimes.

Today i started again got to the third challenge before anything broke which is normal, when i atempted to go back again the time out stayed however when i made another one from stratch it passed straght away everytime so i figure i must be connecting to the db fine, the timeout is throwing me however.

on the third challenge i went though line by line and figured out where the error is occouring.
This is my current atempt:


(submitting this link tho:https://tropical-grey.glitch.me/)

the error message is:
// running tests
Creating and saving a db item should succeed (Test timed out)
// tests completed

now im not 100% sure if im right but all i can see by testing line by line the timeout occours when i put
done(null , data); into the if statement like so

 if(err) return done(err);
                   done(null , data);

AND uncomment the data. so i figure either nothing is being passed as data or what is being passed cannot be processed by the done function causing the timeout

as to why when i comment out all of this code so its in a the state which passed the previous challenges and try and pass the previous challenges again it still has the same timeout error untill i create a new glitch project im not sure but hopefully i can get past this challenge above and it wont be a reoccouring problem.

With your current Glitch project shown above, the first 3 challenges all pass.

Can you provide the link to the challenge url you are currently not passing?

thanks very much for the replys!

The Challenge is this one:
https://www.freecodecamp.org/learn/apis-and-microservices/mongodb-and-mongoose/create-and-save-a-record-of-a-model

The message i get when i try to submit is this
// running tests
Creating and saving a db item should succeed (Test timed out)
// tests completed

@aoc386 Can you add the following console.log statements to your current createAndSavePerson function and then tell us what you see in the Node console when you click Run the Tests?

var createAndSavePerson = (done) => {
  const person = new Person({name:"norman",
                             age:17,
                             favoriteFoods:["foods"]
                            })
  
  person.save((err , data) => {
    if (err) {
      console.log('error');
      done(err)
    } else {
      console.log('calling done')
      done(null , data);
    }
  })
                             
};

Im sorry i havnt seen the ‘run the tests’ in any part of glitch so far so i dont know if im understanding correctly, however when i add those lines in im getting the same timeout error when i try and submit the url.

the node console says:

2 // this is from the console.log testing to see if db has connected

5:17 PM

:fireworks::pizza: Your app is listening on port 3000

Edit: ok ive found a second console which must be the node console but i still dont see a way to run the tests

I meant to say when you click the “Submit and go to my next challenge” button.

ah ok yea it still times out

But what gets displayed to the Node console?

sorry for the misunderstanding.

i click submit i check the node console and nothing changes atall

just says:
Could not find Node 4.4.5, using Node 10

app@tropical-grey:~ 18:13

So you added the console.log statements above and do not see anything in the Node console when you submit the Glitch url?

Can you post the exact url you are submitting?

yes extact url is

https://tropical-grey.glitch.me/

If you added both of the console.log statements where I specified in your current project, you should see something like the following when you submit the above url. If not, then you will need to check your browser’s console to see if anything gets displayed there when you submit the url. I have forked your Glitch project and only changed to my own MONGO_URI and can pass the Create and Save a Record of a Model challenge without any problem.

my browser console is displaying alot of stuff does this help atall?

I suggest you clear the browser console before submitting the url. Also, you still have not added the console.log statements like I said in one of my previous posts. That is probably why you are not seeing anything in the Node console.

sorry i c/p’d the wrong one that was another atempt i had done earlier (you can see the url is differnt too)
this is the correct one:

Please clear the browser console first before submitting the url and taking the screenshot. If you are still seeing those errors in the browser console after doing so, then there is something else unrelated going on here.