Skip to content

Instantly share code, notes, and snippets.

@donjosef
Last active September 26, 2019 15:37
Show Gist options
  • Save donjosef/afbf9c531cf40fac18f40e33a7134df0 to your computer and use it in GitHub Desktop.
Save donjosef/afbf9c531cf40fac18f40e33a7134df0 to your computer and use it in GitHub Desktop.
Connect to database
const mongoose = require('mongoose');
//connect our server to database created with atlas
//Be sure to type this at the very bottom of the file, AFTER all the app.use()
mongoose
.connect('mongodb+srv://giuseppe:<password>@cluster0-rchmx.mongodb.net/test?retryWrites=true&w=majority')
.then(() => {
app.listen(8080, () => {
console.log('Server listening on port 8080...')
})
})
.catch(err => console.log('Error with mongoose connection', err))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment