try{
//3.检查该邮箱是否注册过
let finResult = await userModel.findOne({email})
if(finResult){
//response.send(`注册失败,${email}邮箱已经被注册了`)
//return
errMsg.emailErr = `注册失败,${email}邮箱已经被注册了`
response.render('register',{errMsg})
}else{
await userModel.create({email,nick_name,password})
console.log(`邮箱为:${email},昵称为:${nick_name}的用户注册成功了!`)
//response.send('注册成功了!')
response.redirect(`/login?email=${email}`)
}
}
catch(err){
//1.计数 2.引入警报模块
console.log(err)
errMsg.networkErr = `阿偶,网络不稳定,稍后重试!`
//response.send('阿偶,网络不稳定,稍后重试!')
response.render('register',{errMsg})
}
})
图片1.png
网友评论