Skip to content

Commit bf1bc11

Browse files
authored
Merge pull request #3566 from saidam90/patch-1
Update part3c.md
2 parents 055ff3f + 99a7673 commit bf1bc11

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/content/3/en/part3c.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,25 @@ const noteSchema = new mongoose.Schema({
389389
const Note = mongoose.model('Note', noteSchema)
390390
```
391391

392+
To avoid authentication issues with the password variable in index.js, we need to create a .env file by running npm install dotenv in the command line. Then, let's create the .env file in the root of your directory. In that file, you should place your URI:
393+
394+
```
395+
MONGODB_URL="mongodb+srv://fullstack:[email protected]/?retryWrites=true&w=majority&appName=db"
396+
```
397+
Don't forget to replace the string with your details.
398+
Once the .env file is ready, remember to add it to your .gitignore file to prevent pushing the password to Git:
399+
400+
```
401+
/node_modules
402+
.env
403+
```
404+
Then, in your index.js file, make the necessary changes with the following line so that your code can access the URL in your .env file:
405+
406+
```
407+
const url = process.env.MONGODB_URL;
408+
409+
```
410+
392411
Let's change the handler for fetching all notes to the following form:
393412

394413
```js

0 commit comments

Comments
 (0)