capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
335 stars 59 forks source link

Unable to request restful APIs #159

Closed kamillumiehr closed 2 years ago

kamillumiehr commented 2 years ago

My application is using restful APIs therefore GET/POST/PUT/DELETE are the common operations. I m using HttpClient of angular/common/http. The application is working fine on web platform without any issue but when I run on electron client I am get an error message "Message: Http failure response for https://myapi"

I also tried the @capacitor-community/http but again it is not working and I m getting the following error

TypeError: Failed to fetch at zone.js:1523 at proto. (zone.js:1015) at request.js:98 at Generator.next () at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25) at asyncToGenerator.js:32 at new ZoneAwarePromise (zone.js:1340) at asyncToGenerator.js:21 at request (request.js:94)

I also tried to use electron remote but it is also null.

IT-MikeS commented 2 years ago

Yeah, this is a known issue, the http lib does not have electron support but I do have some plans moving forward

filpet95 commented 2 years ago

I have faced this issue as well. My temporary appoach until it is solved is defining a class of helper methods (get, post etc) selecting axios if platform is PWA or electron, otherwise using the http plugin.

IT-MikeS commented 2 years ago

Looks like there may be a fix in http coming at some point

https://github.com/capacitor-community/http/pull/218