basir / node-react-ecommerce

Build ECommerce Website Like Amazon By React & Node & MongoDB
https://node-react-ecommerce-app.herokuapp.com/
1.68k stars 784 forks source link

problem with mongodb cannot get connected #46

Closed Yassineaeh closed 4 years ago

Yassineaeh commented 4 years ago

ive changed it to mongoAtlas the mongo to connect it via the cloud but it gives me this issue ps : it didnt work with mongodb because i have it already installed but i dont know how to create another database

basir commented 4 years ago

First don’t share your database password Second you wrapped your db name, password between <> . Get rid of them

On Sat, Jun 13, 2020 at 5:06 AM Yassineaeh notifications@github.com wrote:

[image: image] https://user-images.githubusercontent.com/34603692/84554951-406b1e80-ad12-11ea-85d1-7a1d89ee57b7.png ive changed it to mongoAtlas the mongo to connect it via the cloud but it gives me this issue ps : it didnt work with mongodb bec

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/basir/node-react-ecommerce/issues/46, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATUFQ6E5PWA2UPNIT7KRFLRWLCXRANCNFSM4N4X25ZA .

Yassineaeh commented 4 years ago

ive got rid of them but it still gaves me the same error !

basir commented 4 years ago

Try to connect to your database with this sample code:

const mongoose = require('mongoose'); mongoose.connect('your-connection', {useNewUrlParser: true, useUnifiedTopology: true}); const Cat = mongoose.model('Cat', { name: String }); const kitty = new Cat({ name: 'Zildjian' }); kitty.save().then(() => console.log('meow'));

If it doesn't work, you need to fix your connection.

On Sat, Jun 13, 2020 at 5:09 PM Yassineaeh notifications@github.com wrote:

ive got rid of them but it still gaves me the same error !

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/basir/node-react-ecommerce/issues/46#issuecomment-643618141, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATUFQ2FDVC7OLV76FPMLEDRWNXQ5ANCNFSM4N4X25ZA .

basir commented 4 years ago

did it fix?

Yassineaeh commented 4 years ago

i dont know where to put this code in order to see if it does work ! i want to know if the data you're getting after you install mongo in the tutorial is fetched from the database or the server ? if its the case should i import data.js manually to mongodb in order to fix it ?

Yassineaeh commented 4 years ago

to be precise when i downloaded the version : Video-16-Manage-Products-Screen (#14) i couldnt fetch the data from the database !

Yassineaeh commented 4 years ago

it's been solved thanks !

basir commented 4 years ago

glad to hear that.

basir commented 4 years ago

i dont know where to put this code in order to see if it does work ! i want to know if the data you're getting after you install mongo in the tutorial is fetched from the database or the server ? if its the case should i import data.js manually to mongodb in order to fix it ?

you need to put that code in an empty test.js file and run it like node test.js to make sure you get no error in console.