Din*_*mar 5 http typescript ionic-framework angular ionic4
我正在尝试从一个简单的 api 获取数据,它在ionic serve (browser) 中工作正常,但是当我构建应用程序时,http 调用不起作用。我的代码是
this.http.get("http://example.com/api/routes").subscribe(response => {
this.routes = response["routes"];
for (let x in this.routes) {
let a = this.routes[x].rou_stops;
let b = a.split(",");
for (let y in b) {
this.newCit.push(b[y]);
}
}
});
Run Code Online (Sandbox Code Playgroud)
请帮助解决这个问题。
我猜你得到这个是因为 android 改变了它的 http 架构。
要使其在 Android 上运行,请转到项目根文件夹。
yourAppFolder > resources > android > xml > network_security_config.xml 将您的网络安全配置更改为打击代码。
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2846 次 |
| 最近记录: |