Standard http client for ionic (Angular)


We are developing an ionic (Angular) application for iOS and android which consumes data from a REST api. We have seen that there are different ways to make http calls, so I would like to ask which http client is the one commonly used in production applications? Is it better to use the Angular client or the capacitor client?

I normally use the HttpClient on Web and the Capacitor HTTP Plugin on native devices :blush: That coupd be archieved via an Interceptor for example, see: GitHub - sean-perkins/ngx-capacitor-http: Zero-config drop in for native HTTP calls with Angular Capacitor applications.

Thank you for your response. Why do you use both clients? Is there any problem with using angular client on ios and andorid?

Not a “problem”, i use it for two reasons:

  1. CORS - with the native plugin you don’t need to worry about CORS and don’t have to add the localhost origins to allowed origins
  2. Performance - In quite huge apps that do very much, moving the http requests to the native layer, can help to improve the performance of the webview
1 Like