Facing error "mongoose" should be connected to a database

Tell us what’s happening:
Hello everyone, I got stuck on the Install and Set Up Mongoose challenge.

I am getting the same error “mongoose should be connected to a database” when trying to submit a solution.

I read through several topics on the same problems, but none of the solutions seems to work in my case.

My app.js_______________________________

let mongoose = require("mongoose");

mongoose.connect(process.env.MONGO_URI, {
  urlEncoded: true,
  useNewUrlParser: true

I tried to put mongoose.connect inside a var but its no hepl

.env file___________________________________


Where myUsername and myPassword are changed to username and password, I am not using any prohibited symbols in them.

Any help and advice appreciated

Your project link(s)

solution: https://4gfgo.sse.codesandbox.io

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36

Challenge: Install and Set Up Mongoose

Link to the challenge:

Welcome there,

When I try to view your app, I see the following error:

exports.createAndSavePerson = createAndSavePerson;

ReferenceError: createAndSavePerson is not defined
    at Object.<anonymous> (/sandbox/myApp.js:66:31)

It seems like you have changed boilerplate code you should not have.

Hope this helps

Thanks for your reply, Unfortunately I was not able to find a mistake.

I assume the issue could have been that I did my project in codesandbox, cause the next day I tried same code in replit and it worked

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.