bug: Http call only work on browser
See original GitHub issueBug Report
Ionic version: [ ] 3.x [x] 4.x [x] 5.x
Current behavior: While running the application on mobile (debug mode), http calls return error as if they are not even called. Error: status: 0 Unknown error.
Expected behavior: Sending/Receiving data should take place, i have been calling the APIs from my browser and it worked just fine.
Related code:
this.getPetTypesSub = this.myService.API_NAME(param).subscribe((data) => {
//doSomething
}, (error) => {
alert(JSON.stringify(error));
});
API_NAME(Param): Observable<any> {
let url = 'API_URL/API_NAME';
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
const options = { headers: headers };
return this.api.post(url , JSON.stringify(Param), options)
.pipe(map(response => { return response.; }));
}
Other information: I tried to call an api that is working on another ionic application (Ionic 3). But calling it from (Ionic 4 - 5) application is not working especially on device.
Ionic info:
Ionic:
Ionic CLI : 5.0.0
Ionic Framework : @ionic/angular 4.4.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 4 other plugins)
Utility:
cordova-res : 0.3.0
native-run : not installed
System:
NodeJS : v10.15.3
npm : 6.9.0
OS : Windows 10
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
GET request works in browser but not in POSTMAN or SOAPUI
I got the exact same issue, requests working from the browser but not using postman. ... It seems like a small bug on...
Read more >55041 - localhost does not resolve when not connected to ...
The resolver seems to be in a strange state - host and dig where not able to resolve localhost, and they should be...
Read more >Cross-Origin Resource Sharing (CORS) - MDN Web Docs
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, ...
Read more >How do you know what's gone wrong when your API request ...
When an API request doesn't work, hopefully the client receives a sensible HTTP error status, like 409 or 500, which is a good...
Read more >Browser-Powered Desync Attacks: A New Frontier in HTTP ...
The recent rise of HTTP Request Smuggling has seen a flood of ... All bug bounties earned during our research are donated to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your issue! Please aware that this Repo are only for Ionic issues. What you describe is more related to Angular and Cordova or Cordova Plugin Ionic Webview. What @KillerCodeMonkey says I also believe: the API server needs CORS enabled and set correctly.
looks like more a config issue https://docs.microsoft.com/en-us/visualstudio/cross-platform/tools-for-cordova/security/whitelists?view=toolsforcordova-2017
maybe you are using a non ssl endpoint or something?