如何通过Ionic-2
中的原生cordova HTTP插件的post方法传递body答案 0 :(得分:0)
从离子2文档中,您可以像这样传递body
。
import { HTTP } from 'ionic-native';
let body = { data: "value" } \\body which you want to send ;
let header = { Authorization: "OAuth2: token" };
HTTP.post('http://ionic.io', body, header)
.then(data => {
console.log(data.status);
console.log(data.data); // data received by server
console.log(data.headers);
})
.catch(error => {
console.log(error.status);
console.log(error.error); // error message as string
console.log(error.headers);
});
答案 1 :(得分:0)
在发布电话之前设置this.setDataSerializer(“json”);