I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Did you add the connection string to the Secrets (environment variables) section? Not sure how replit handles .env files created after they got deprecated but I would suggest you try using the interface for adding the connection string and not the .env file.
The MongoDB Atlas Tutorial should have all you need for the DB setup.
As for the connection string. Click the padlock icon and add MONGO_URI for the key, then add the connection string you got when setting up the DB for the value.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I have also redacted your your MongoDB Atlas database URI because you just gave out your password and username.
You need to be careful not to pass out that sensitive information.
This looks like a new challenge though.
If so, you will need to make a new topic with the challenge link and describe what error messages you are getting.
If you are asking for help with the Install and Set Up Mongoose challenge then the latest code you provided looks really different from the starter code provided for you.
var express = require('express');
var app = express();
// enable CORS ([https://en.wikipedia.org/wiki/Cross-origin_resource_sharing](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing))
// so that your API is remotely testable by FCC
var cors = require('cors');
app.use(cors({optionsSuccessStatus: 200})); // some legacy browsers choke on 204
// [http://expressjs.com/en/starter/static-files.html](http://expressjs.com/en/starter/static-files.html)
app.use(express.static('public'));
// [http://expressjs.com/en/starter/basic-routing.html](http://expressjs.com/en/starter/basic-routing.html)
app.get("/", function (req, res) {
res.sendFile(__dirname + '/views/index.html');
});
// your first API endpoint...
app.get("/api/timestamp/:timestamp", function (req, res) {
let timestamp = req.params.timestamp;
if(timestamp.match(/\d{5,}/)){
timestamp = +timestamp;
}
let date = new Date(timestamp);
if(date.toUTCString() == "Invalid Date"){
res.json({error: data.toUTCString()})
}
res.json({ unix: date.valueOf(), utc: date.toUTCString()});
});
app.get("/api/timestamp/", (req, res) => {
let date = new Date();
res.json({ unix: date.valueOf(), utc: date.toUTCString()});
})
// listen for requests :)
var listener = app.listen(process.env.PORT, function () {
console.log('Your app is listening on port ' + listener.address().port);
});