【问题标题】:fetch data from web API working in the browser but not working in the device ionic app [closed]从在浏览器中工作但在设备离子应用程序中不工作的 Web API 获取数据[关闭]
【发布时间】:2019-12-17 23:04:26
【问题描述】:

我构建了 ionic 应用程序项目。并使用 Web API 从 SQL 服务器获取数据。该项目在浏览器中工作但在设备中不工作

这里是代码


synAccountFromServer() {
    this.dataServices.getAccountFromServer().subscribe(
      d => {
        alert('Data Success');
      },
      err => {
        console.log('Error11: ' + JSON.stringify(err));
      }
    );


getAccountFromServer() {
    //alert('start get Datat from serve');   
    return this.http.get(this.urlGetAccounts);
  }

【问题讨论】:

    标签: api web-services http web ionic4


    【解决方案1】:

    通常这是因为您在源代码中使用的是http 而不是https

    检查this.urlGetAccounts 的值是否以https 开头。

    如果是这样,则可能是 CORS 问题,而不是 Ionic 问题。它要求您的服务器与 web api 进行不同的配置。

    【讨论】:

    • 谢谢。它奏效了。但是您应该将 IIS 配置编辑为 Https
    • 太好了,如果解决了,我将不胜感激您将其标记为答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多