postman에서 send를 누루면
Cannot POST /register << 이런 에러가 나와요
const express = require('express') //express module을 가져와라
const app = express() //express() function 을 이용해서 express app 을 만듬
const port = 5100
const mongoose = require('mongoose')
const bodyParser = require('body-parser');
const {User} = require("./models/User");
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
mongoose.connect('mongodb+srv://000000@0000000.7lopm.mongodb.net/myFirstDatabase?retryWrites=true&w=majority', {
useNewUrlParser : true, useUnifiedTopology : true, useCreateIndex : true, useFindAndModify : false
}).then(()=> console.log('MongoDB Connected..')).catch(err => console.log(err))
app.get('/', (req, res) => {
res.send('Hello World!')
})app.post('/register', (req, res) => {
const user = new User(req.body);
user.save((err, userInfo) => {
if(err) return res.json({success : false, err})
return res.status(200).json({
success : true
})
})
})