Android端,我们在POST请求时
componentWillMount(){@H_403_3@
var body = {"id": 1};
fetch("http://xxx",{
method: "POST",@H_403_3@ body: JSON.stringify(body),@H_403_3@ }) @H_403_3@ .then((response) => response.json()) @H_403_3@ .then((responseData) => { @H_403_3@ ToastAndroid.show(""+responseData.data,ToastAndroid.SHORT); @H_403_3@ }) @H_403_3@ .catch((error) => { @H_403_3@ ToastAndroid.show("err :"+error ,ToastAndroid.SHORT); @H_403_3@}).done();
}
总会报错Network request Failed。
其实这是针对Android的HTTP请求的协议
解决方法是:Post数据要带headers,里面要有Content-Type,
即: