Skip to content

Instantly share code, notes, and snippets.

@piyushgarg-dev
Created April 25, 2020 12:22
Show Gist options
  • Select an option

  • Save piyushgarg-dev/ddf9cd46e7f14c55a99daba79249becd to your computer and use it in GitHub Desktop.

Select an option

Save piyushgarg-dev/ddf9cd46e7f14c55a99daba79249becd to your computer and use it in GitHub Desktop.
const express = require('express');
const mongoose = require('mongoose');
const app = express()
mongoose.connect(
`mongodb+srv://piyushgarg:hello123@cluster0-2bghc.mongodb.net/test?retryWrites=true&w=majority`
)
.then(() => console.log('MongoDB Connect'))
.catch((err) => console.log(`Error Occured ${err}`))
app.get('/', (req, res) => {
res.send('Welcome to my API');
})
app.listen(9000, () => console.log('Server Started at PORT 9000'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment