Ionic-2:在本机HTTP cordova插件中通过post方法传递body

时间:2016-12-13 09:07:53

标签: http angular ionic2

如何通过Ionic-2

中的原生cordova HTTP插件的post方法传递body

2 个答案:

答案 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”);