app.post('/register', function(요청,응답){
console.log('전송왔음?')
db.collection('registerCount').findOne({name:"아이디번호"},function(에러, 결과){
var totalId = 결과.totalId;
db.collection('register').findOne({id: 요청.body.registerId},function(에러,결과){
console.log(요청.body.registerId)
console.log(결과)
if(결과 == null){
db.collection('register').insertOne({id: 요청.body.registerId, 비밀번호 : 요청.body.registerPw ,_id : totalId}, function(에러,결과){
db.collection('registerCount').updateOne({name : '아이디번호'},{ $inc :{totalId:1}},function(에러,결과){
if(에러){
return console.log(에러)
}else{
console.log('성공')
응답.redirect('/')
}
})
})
}else{
console.log('아이디 중복')
var registerNum = 1;
응답.json(registerNum)
}
})
})
});
현재 이상황에서 결과값이 null 이 아닐시에 DB에 저장까지 되는게 확인이 되는데 redirect가 되지 않는현상이 나타납니다..
어떻게 해야할까요 ?