我正在尝试在 Ionic 2 中登录我的应用程序时发出 POST 请求。
var link = 'https://domain.name/login' + '?appname=' + "name";
var data = JSON.stringify({username: "0000000", password: "12345678"});
var headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http.post(link, data, {headers: headers})
.subscribe(data => {
var alert = Alert.create({
title: "Data String",
subTitle: data.json().data,
buttons: ["close"]
});
this.nav.present(alert);
}, error => {
console.log(JSON.stringify(error.json()));
});
但它给出了以下错误。虽然我已经设置了内容类型,但它给出了以下错误。
415 Unsupported Media Type
{"Message":"The request entity's media type 'text/plain' is not supported for this resource."}