Did you set process.env.MONGO_URI equal to the connection URL you got from MongoDB Atlas?
yes is did
mongodb+srv://amitamora:@cluster0-2cjqn.mongodb.net/test?retryWrites=true&w=majority
mongodb+srv://amitamora:password@cluster0-2cjqn.mongodb.net/test?retryWrites=true&w=majority
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
GLITCH_DEBUGGER=true
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
SECRET=
MADE_WITH=
MONGO_URI=mongodb+srv://:@-vlas9.mongodb.net/test?retryWrites=true
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.
mongodb+srv://amitamora:<thereShouldBeAPasswordHere>@cluster0-2cjqn.mongodb.net/test?retryWrites=true&w=majority
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.>";
mongoose.connect(process.env.MONGO_URI);
yes worked i didnt added mlab link
HI
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() });
}else{
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!