Please help with install mongoose challenge

Hello,

I just went to Install and Set Up Mongoose and can you tell me where is the wrong

require('dotenv').config();
const mongoose = require("mongoose");
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

let Person;

const createAndSavePerson = (done) => {
done(null /*, data*/);
};

const createManyPeople = (arrayOfPeople, done) => {
done(null /*, data*/);
};

const findPeopleByName = (personName, done) => {
done(null /*, data*/);
};

const findOneByFood = (food, done) => {
done(null /*, data*/);
};

const findPersonById = (personId, done) => {
done(null /*, data*/);
};

const findEditThenSave = (personId, done) => {
const foodToAdd = "hamburger";

done(null /*, data*/);
};

const findAndUpdate = (personName, done) => {
const ageToSet = 20;

done(null /*, data*/);
};

const removeById = (personId, done) => {
done(null /*, data*/);
};

const removeManyPeople = (done) => {
const nameToRemove = "Mary";

done(null /*, data*/);
};

const queryChain = (done) => {
const foodToSearch = "burrito";

done(null /*, data*/);
};

/** **Well Done !!**
/* You completed these challenges, let's go celebrate !
*/

//----- **DO NOT EDIT BELOW THIS LINE** ----------------------------------

exports.PersonModel = Person;
exports.createAndSavePerson = createAndSavePerson;
exports.findPeopleByName = findPeopleByName;
exports.findOneByFood = findOneByFood;
exports.findPersonById = findPersonById;
exports.findEditThenSave = findEditThenSave;
exports.findAndUpdate = findAndUpdate;
exports.createManyPeople = createManyPeople;
exports.removeById = removeById;
exports.removeManyPeople = removeManyPeople;
exports.queryChain = queryChain;

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.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

HI @mars !

I moved your question to a new topic.

What do the error messages say?
Did you add your mongo_uri to the secrets tab?

6 posts were split to a new topic: Please help with stock price checker

  1. I assume you followed the steps in MongoDB Atlas Tutorial – How to Get Started already?

  2. 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.

No but can you tell me the steps to do it.

Do what?

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.

If you need a visual for setting up MongoDb atlas then there are a few tutorials on youtube.

Here is one. I would only watch the first 5:30

Just make sure to have your actual username and password there.

1 Like

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.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

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.

yes

Secrets

System environment variables

key
MONGO_URI
value
REDACTED
Delete

CancelSave

key

value

Add new secret

Use secrets in the repl

To use secrets in Node.js

Access the secret by key as an environment variable

MONGO_URI

const mySecret = process.env[‘MONGO_URI’]

Insert →

Edit raw JSON (Advanced)

Open raw editor

Are you working on a new challenge?
If so, please create a new topic.

You can create a new topic by using the Ask for Help button in the challenge.

Screen Shot 2021-05-19 at 4.25.03 PM

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.

Hope that makes sense!

What happened to all of the starter code?

You need to have the starter files to pass these challenges.

The latest code you posted is missing a lot of important information.

I would suggest starting over and making sure to use starter code that was provided for you.

Here are the starter replit files

type or paste code here

I merged your last post into here since it is the same challenge.

But you need to stop sharing your Mongo uri.

It is not much of a secret key if everyone can see it.
You need to delete it out of the sample.env file.

Also you should not write it here

const uri = "REDACTED";

You need to add it to the secrets tab so no one can see it
Then you should use that variable in your code.

Please help me I need to finish from it

You should start from this code that you posted week ago.

require('dotenv').config();
const mongoose = require("mongoose");
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

let Person;

const createAndSavePerson = (done) => {
done(null /*, data*/);
};

const createManyPeople = (arrayOfPeople, done) => {
done(null /*, data*/);
};

const findPeopleByName = (personName, done) => {
done(null /*, data*/);
};

const findOneByFood = (food, done) => {
done(null /*, data*/);
};

const findPersonById = (personId, done) => {
done(null /*, data*/);
};

const findEditThenSave = (personId, done) => {
const foodToAdd = "hamburger";

done(null /*, data*/);
};

const findAndUpdate = (personName, done) => {
const ageToSet = 20;

done(null /*, data*/);
};

const removeById = (personId, done) => {
done(null /*, data*/);
};

const removeManyPeople = (done) => {
const nameToRemove = "Mary";

done(null /*, data*/);
};

const queryChain = (done) => {
const foodToSearch = "burrito";

done(null /*, data*/);
};

/** **Well Done !!**
/* You completed these challenges, let's go celebrate !
*/

//----- **DO NOT EDIT BELOW THIS LINE** ----------------------------------

exports.PersonModel = Person;
exports.createAndSavePerson = createAndSavePerson;
exports.findPeopleByName = findPeopleByName;
exports.findOneByFood = findOneByFood;
exports.findPersonById = findPersonById;
exports.findEditThenSave = findEditThenSave;
exports.findAndUpdate = findAndUpdate;
exports.createManyPeople = createManyPeople;
exports.removeById = removeById;
exports.removeManyPeople = removeManyPeople;
exports.queryChain = queryChain;

Once you successfully add the mongo uri to the secrets tab and no where else then the problem is with the uri itself.

I tried getting it to work with your uri but it didn’t pass.

When I used my uri, all of the tests passed.

I would double check and make sure you are using the correct value.
Log back into the account and make sure it is correct.

Hi there,

Can you tell me where is the mistake?

Timestamp Microservice

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);
});

Please post a link to your project on repl so we have a live example.


I’ve edited your post for readability…

https://boilerplate-project-timestamp-5.memojojo.repl.co