@kristofberge wrote:
I’m new to Ionic and will be working on a legacy Android project. As far as I know, I installed everything I need on my machine. I can run the app, when I want to do an API call, it always returns an empty object with status 0. It doesn’t matter which API I use or which http verb. Also, on my colleague’s machine, the same code with the same API works perfectly. Here’s my code:
let options = new RequestOptions({ headers: new Headers({ 'Access-Control-Allow-Origin': '*' }), withCredentials: false}); this.http.get('http://dummy.restapiexample.com/api/v1/employees', options2).subscribe( data => { debugger; var test = data; }, err => { debugger; var test = err; });
As you can see I’m calling a dummy API and I’m setting the Access-Control-Allow-Origin header. This should simply return a json array, but instead it always falls into the err handler with a status code of 0. Is there something I´m missing? What can I do here, I’m out of options.
Thank you.PS: here´s my ionic info:
Ionic: Ionic CLI : 5.4.16 (C:\Users\Kristof\AppData\Roaming\npm\node_modules\ionic) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.4 Cordova: Cordova CLI : 8.1.1 (cordova-lib@8.1.0) Cordova Platforms : android 7.1.4 Cordova Plugins : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 1.2.1, (and 14 other plugins) Utility: cordova-res : not installed native-run : 1.0.0 System: Android SDK Tools : 26.1.1 (C:\Users\Kristof\AppData\Local\Android\SDK) NodeJS : v12.16.3 (C:\Program Files\nodejs\node.exe) npm : 6.14.4 OS : Windows 10
Posts: 1
Participants: 1