想實現(xiàn)前端發(fā)送注冊的賬號密碼數(shù)據(jù)通過Post請求給后臺,但是后臺該咋寫啊。我一點注冊,它就提示報錯說“Cannot POST /”這是我的vue.js前端代碼register(){ if(this.username == ''|| this.password == ''){
alert('請輸入用戶名或密碼')
}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后臺的,用了express 和 mongooserouter.post('/register/qian',function(req,res){req.on('data',function(data){
obj=JSON.parse(data) console.log(obj)
res.send('數(shù)據(jù)已接受')
})})
添加回答
舉報
0/150
提交
取消