问个问题 Uncaught (in promise)
发布于 8 年前 作者 Myth52125 12931 次预览 最后一次回复是 8 年前 来自 问答
是这个样子的 vue+vue-resource+express组合 然后在下面这里遇到问题了
client
this.$http.jsonp('http://localhost:3300/register', { params: { name: this.name, password: this.password, repassword: this.repassword } }, {})
.then(function (response) {
console.log(response.data.state)
})
server
app.get('/register', function (req, res) {
userTools.create(user).then(function(result){
res.jsonp(result)
}).catch(function(err){
res.jsonp(data)
})
})
这样就会出错
如果server改为下面这样就不出包错了
app.get('/register', function (req, res) {
res.jsonp(data)
}
这是问什么啊?
5 回复
@SvenZhao 这应该不是res的问题。
client catch 一下然后输出一下看看error是什么
@imhered 输出一样,不过上面最后一个不报红的了,是console出来的,但是内容不变
res.type(‘application/javascript’).jsonp(xxx)