Did you set process.env.MONGO_URI equal to the connection URL you got from MongoDB Atlas?

yes is did


but i’m still getting

throw new MongooseError('The uri parameter to openUri() must be a ’ +

MongooseError: The uri parameter to openUri() must be a string, got “undefined”. Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string

in .env file i copied the same

Environment Config

store your secrets and config variables in here

only invited collaborators will be able to see your .env values

reference these in your code with process.env.SECRET


note: .env is a shell file so there can’t be spaces around =

with my credentials

but still im getting
“mongoose” should be connected to a database
in FCC

First, it looks like your URL to connect is missing the password.

Did you see on the instructions how you should put the password in the URL? Try going to the Connect section again if you don’t know what I mean.

This is what worked for me. Put all of this in myApp.js but put in your URL.

const mongoose = require('mongoose');
process.env.MONGO_URI = "<this is my URL, make sure to wrap in quotes.>";

yes worked i didnt added mlab link

1 Like

I getting this for API microservice challange
// running tests
It should return the expected error message for an invalid date
// tests completed

I endup writing code didnt worked finaly icopied from help still it didnt worked for me
pp.get("/api/timestamp/:date_string", (req, res) => {
let dateString = req.params.date_string;

if (/\d{5,}/.test(dateString)) {
let dateInt = parseInt(dateString);
res.json({ unix: dateString, utc: new Date(dateInt).toUTCString() });
let dateObject = new Date(dateString);
if (dateObject.toString() === “Invalid Date”) {
res.json({“unix”: dateObject.getTime(), “utc” : dateObject.toString()});
} else {
res.json({ unix: dateObject.valueOf(), utc: dateObject.toUTCString() });


can you help me with this

For whatever reason, when I click on the link on the “Introduction to the MongoDB and Mongoose Challenges” page to start the project on Glitch (to clone the starter project), I am getting an empty project that I can’t edit. Your link worked great for me. Thanks!

1 Like