我已尝试添加android:usesCleartextTraffic =“ true”的解决方案 在清单文件中,但不起作用。
items.component.ts方法
private serverUrl = "http://portal.smallborrowing.com/get_user.php";
extractData() {
this.myService.getData(this.serverUrl).subscribe(data => this.profile=data);
console.log(this.profile);
}
item.service.ts方法
getData(serverUrl) {
return this.http.get(serverUrl);
}
错误
错误
{
"headers": {
"normalizedNames": {},
"lazyUpdate": null,
"headers": {}
},
"status": 0,
"statusText": "Unknown Error",
"url": "http://portal.smallborrowing.com/get_user.php",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure response for http://portal.smallborrowing.com/get_user.php: 0 Unknown Error",
"error": {
JS: "originalStack": "Error: java.io.IOException: Cleartext HTTP traffic to portal.smallborrowing.com not permitted\n at new ZoneAwareError (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:76023:33)\n at onRequestComplete (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:95301:34)\n at Object.onComplete (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:95290:13)",
JS: "zoneAwareStack": "Error: java.io.IOException: Cleartext HTTP traffic to portal.smallborrowing.com not permitted\n at onRequestComplete (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:953...
get_user.php返回此数据
{"email":"John","password":"password"}