【发布时间】:2016-05-21 12:37:00
【问题描述】:
这是我的 HTTP 服务:
postData(name, country) {
var body = JSON.stringify({
"name":name,
"country":country
});
console.log(name); // it outpus the correct value
console.log(country); // it outpus the correct value
return this.http.post('http://178.62.58.150:5000/api/cosmo/',body)
.map(res => {
res.text();
console.log(res.text());
})
.do(data => {
this.data = data;
// console.log(this.data);
})
}
似乎它没有将正文发送到 POST 请求。
这些输出正确的body值
console.log(name);
console.log(country);
但是
console.log(res.text());
它给了我一个数据库验证错误,它指出 body 和 country 是必需的...
如何正确发送正文?
附: : 我用 POSTMAN 测试过,效果很好!
【问题讨论】:
标签: node.js http angular ionic2 angular2-services