I cant retrieve data from server when I use android studio virtual emulator

好久不见. 提交于 2019-12-02 23:01:54

问题


I have an app, that works fine on browser, but i run it on the emulator it cant retrieve data from the server I got this error :

polyfills.js:5601 OPTIONS http://localhost:3005/api/posts/toto net::ERR_CONNECTION_REFUSED scheduleTask @ polyfills.js:5601 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ polyfills.js:2768 onScheduleTask @ polyfills.js:2659 capacitor-runtime.js:81 ERROR TypeError: You provided 'function (error) { // TODO: send the error to remote logging infrastructure console.error(error); // log to console instead // TODO: better job of transforming error for user consumption _this.log(operation + " failed: " + error.message); // Let the app keep running by returning an empty result. return Object(rxjs__WEBPACK_IMPORTED_MODULE_3__["of"])(result); }' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

here's my method to retrieve data from server : ```

    getDataScanedFromBD() {
    const loading = await this.loadingController.create({
      message: "Loading"
    });

    await loading.present();
    await
    this.api.getProductById("toto").subscribe(
      result => {
        this.ObjectResult = result;
        console.log(JSON.stringify(this.ObjectResult));
        //loading.dismiss();
      },
      err => {
        console.log(err);
        //loading.dismiss();
      }
    );
  }
```

I'm using IONIC 4, can anyone help please ?

来源:https://stackoverflow.com/questions/56201989/i-cant-retrieve-data-from-server-when-i-use-android-studio-virtual-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!