想實(shí)現(xiàn)前端發(fā)送注冊(cè)的賬號(hào)密碼數(shù)據(jù)通過Post請(qǐng)求給后臺(tái),但是后臺(tái)該咋寫啊。我一點(diǎn)注冊(cè),它就提示報(bào)錯(cuò)說“Cannot POST /”這是我的vue.js前端代碼register(){ if(this.username == ''|| this.password == ''){
alert('請(qǐng)輸入用戶名或密碼')
}else{
let data = {'username':this.username,'password':this.password} this.$axios.post('/register/qian',data)
.then((res)=>{
console.log(res) this.$router.push('register')
})
}
}這是node.js后臺(tái)的,用了express 和 mongooserouter.post('/register/qian',function(req,res){req.on('data',function(data){
obj=JSON.parse(data) console.log(obj)
res.send('數(shù)據(jù)已接受')
})})
添加回答
舉報(bào)
0/150
提交
取消