리액트- #3 몽고DB 연결

Jeongwon·2022년 1월 20일
0

리액트

목록 보기
2/6

index.js

const app = express()
const port = 5000

const mongoose = require('mongoose')
mongoose.connect('mongodb+srv://hijw01:1q2w3e4r5t@boilerplate.kvilj.mongodb.net/myFirstDatabase?retryWrites=true&w=majority', {
}).then(() => console.log('MongoDB Connected...'))
  .catch(err => console.log(err))


app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

package.json

{
  "name": "boiler-plate",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "jeongwon",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.2",
    "mongoose": "^6.1.7"
  }
}

1) 터미널

2) localhost:5000

profile
(❁´◡`❁)

0개의 댓글

Powered by GraphCDN, the GraphQL CDN