问题
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