register.js
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const express = require("express");
const bodyParser = require("body-parser");
const router = express.Router();
/////////////
const {User}=require('../models');
//////////
router.get('/',(req,res)=>{
res.send('회원가입 페이지');
});
//회원가입
router.post('/',(req,res)=>{
User.findOne({
where:{name: req.body.Id}
})
.then((result)=>{
//id가 중복되지 않는 경우
if(result === null || result === undefined){
User.create({
name: req.body.Id,
pw:req.body.Password,
personality:req.body.Personality,
status:false
})
console.log(req.body);
return res.sendStatus(200);
}
//id중복
else{
console.log("중복된 id");
return res.sendStatus(401);
}
})
});
//라우트 매개변수사용
//뒤에 위치 요구
router.get("/:id",(req,res)=>{
console.log(req.params, req.query);
req.body;
});
module.exports = router;