cordova-plugin-advanced-http vs @angular/common/http
I want to create an API helper class to serve for all types of rest api calls in the app. I have been using the angular httpClient class
import {HttpClient} from '@angular/common/http'
to do API interaction but recently came across https://ionicframework.com/docs/native/http/
Can anybody describe the difference between the two so that I could decide which one would be better as per my requirement.

add a comment |
I want to create an API helper class to serve for all types of rest api calls in the app. I have been using the angular httpClient class
import {HttpClient} from '@angular/common/http'
to do API interaction but recently came across https://ionicframework.com/docs/native/http/
Can anybody describe the difference between the two so that I could decide which one would be better as per my requirement.

HttpClient will send http requests from webview without using native http calls. It may produce CORS issue if your api server is not configured to serve cross origin requests.
– Omurbek Kadyrbekov
Jan 2 at 8:08
add a comment |
I want to create an API helper class to serve for all types of rest api calls in the app. I have been using the angular httpClient class
import {HttpClient} from '@angular/common/http'
to do API interaction but recently came across https://ionicframework.com/docs/native/http/
Can anybody describe the difference between the two so that I could decide which one would be better as per my requirement.

I want to create an API helper class to serve for all types of rest api calls in the app. I have been using the angular httpClient class
import {HttpClient} from '@angular/common/http'
to do API interaction but recently came across https://ionicframework.com/docs/native/http/
Can anybody describe the difference between the two so that I could decide which one would be better as per my requirement.


edited Jan 2 at 9:45
Dale Burrell
3,39052655
3,39052655
asked Jan 2 at 8:05
ApogeeApogee
314113
314113
HttpClient will send http requests from webview without using native http calls. It may produce CORS issue if your api server is not configured to serve cross origin requests.
– Omurbek Kadyrbekov
Jan 2 at 8:08
add a comment |
HttpClient will send http requests from webview without using native http calls. It may produce CORS issue if your api server is not configured to serve cross origin requests.
– Omurbek Kadyrbekov
Jan 2 at 8:08
HttpClient will send http requests from webview without using native http calls. It may produce CORS issue if your api server is not configured to serve cross origin requests.
– Omurbek Kadyrbekov
Jan 2 at 8:08
HttpClient will send http requests from webview without using native http calls. It may produce CORS issue if your api server is not configured to serve cross origin requests.
– Omurbek Kadyrbekov
Jan 2 at 8:08
add a comment |
1 Answer
1
active
oldest
votes
For starters, Angulars Http Module is based on Observables which are widely used within Angular and thus Ionic themselves. The Ionic Http Module instead is based on Promises, which itself is totally fine if you want to use them.
Since this is an Ionic Native Module this also means that the app is not going to make these requests using either the underlying Java (Android) or Objective-C (iOS) function instead of a Javascript function (Please anybody correct me if I am wrong here)
However the main advantages are listed on the Github Repo of the Ionic Http Module:
- Background threading - all requests are done in a background thread.
- Handling of HTTP code 401 - read more at Issue CB-2415.
- SSL Pinning - read more at LumberBlog.
The first point seems to be the most appealing, since it is a feature which is not merely solving a problem but adding functionality.
I cannot tell exactly how big of an advantage it is to run these in a background thread but I also doubt that this will have a big impact unless your app is very network-expensive.
So Ionics native module solves exactly these problems which apparently come with using plain Javascript functions for making http requests from a containered mobile app.
I would say that the Ionic Native solution should only be used in case you encounter any of the above problems.
If not, you would simply add a new dependency which uses another paradigm (promises) than probably any tutorial on Angular which you can find. You simply reduce complexity and bundle size by not using it if it isn't needed.
Angular comes bundled with the Http Module and it is well maintained, also you will find much more help online for this package.
Greatly explained. By your explanation I feel I should go with angular httpClient. But the reason I got attracted towards ionic native http is, "setHeader(host, header, value)" >> Set a header for all future requests. Takes a hostname, a header and a value. Is something similar available in angular httpClient ?
– Apogee
Jan 2 at 10:49
Sadly I believe that this is not provided by the Angular module itself. However it is really easy to achieve the same thing. One way is to go ahead and write your own request-service which wraps the angular http methods and set the headers there. Another way to achieve the same thing would be to write an interceptor, which modifies each request: theinfogrid.com/tech/developers/angular/…
– mchl18
Jan 2 at 15:18
I'll look into interceptor.. Thanks for your time. I'll accept your answer :)
– Apogee
Jan 3 at 2:32
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003077%2fcordova-plugin-advanced-http-vs-angular-common-http%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For starters, Angulars Http Module is based on Observables which are widely used within Angular and thus Ionic themselves. The Ionic Http Module instead is based on Promises, which itself is totally fine if you want to use them.
Since this is an Ionic Native Module this also means that the app is not going to make these requests using either the underlying Java (Android) or Objective-C (iOS) function instead of a Javascript function (Please anybody correct me if I am wrong here)
However the main advantages are listed on the Github Repo of the Ionic Http Module:
- Background threading - all requests are done in a background thread.
- Handling of HTTP code 401 - read more at Issue CB-2415.
- SSL Pinning - read more at LumberBlog.
The first point seems to be the most appealing, since it is a feature which is not merely solving a problem but adding functionality.
I cannot tell exactly how big of an advantage it is to run these in a background thread but I also doubt that this will have a big impact unless your app is very network-expensive.
So Ionics native module solves exactly these problems which apparently come with using plain Javascript functions for making http requests from a containered mobile app.
I would say that the Ionic Native solution should only be used in case you encounter any of the above problems.
If not, you would simply add a new dependency which uses another paradigm (promises) than probably any tutorial on Angular which you can find. You simply reduce complexity and bundle size by not using it if it isn't needed.
Angular comes bundled with the Http Module and it is well maintained, also you will find much more help online for this package.
Greatly explained. By your explanation I feel I should go with angular httpClient. But the reason I got attracted towards ionic native http is, "setHeader(host, header, value)" >> Set a header for all future requests. Takes a hostname, a header and a value. Is something similar available in angular httpClient ?
– Apogee
Jan 2 at 10:49
Sadly I believe that this is not provided by the Angular module itself. However it is really easy to achieve the same thing. One way is to go ahead and write your own request-service which wraps the angular http methods and set the headers there. Another way to achieve the same thing would be to write an interceptor, which modifies each request: theinfogrid.com/tech/developers/angular/…
– mchl18
Jan 2 at 15:18
I'll look into interceptor.. Thanks for your time. I'll accept your answer :)
– Apogee
Jan 3 at 2:32
add a comment |
For starters, Angulars Http Module is based on Observables which are widely used within Angular and thus Ionic themselves. The Ionic Http Module instead is based on Promises, which itself is totally fine if you want to use them.
Since this is an Ionic Native Module this also means that the app is not going to make these requests using either the underlying Java (Android) or Objective-C (iOS) function instead of a Javascript function (Please anybody correct me if I am wrong here)
However the main advantages are listed on the Github Repo of the Ionic Http Module:
- Background threading - all requests are done in a background thread.
- Handling of HTTP code 401 - read more at Issue CB-2415.
- SSL Pinning - read more at LumberBlog.
The first point seems to be the most appealing, since it is a feature which is not merely solving a problem but adding functionality.
I cannot tell exactly how big of an advantage it is to run these in a background thread but I also doubt that this will have a big impact unless your app is very network-expensive.
So Ionics native module solves exactly these problems which apparently come with using plain Javascript functions for making http requests from a containered mobile app.
I would say that the Ionic Native solution should only be used in case you encounter any of the above problems.
If not, you would simply add a new dependency which uses another paradigm (promises) than probably any tutorial on Angular which you can find. You simply reduce complexity and bundle size by not using it if it isn't needed.
Angular comes bundled with the Http Module and it is well maintained, also you will find much more help online for this package.
Greatly explained. By your explanation I feel I should go with angular httpClient. But the reason I got attracted towards ionic native http is, "setHeader(host, header, value)" >> Set a header for all future requests. Takes a hostname, a header and a value. Is something similar available in angular httpClient ?
– Apogee
Jan 2 at 10:49
Sadly I believe that this is not provided by the Angular module itself. However it is really easy to achieve the same thing. One way is to go ahead and write your own request-service which wraps the angular http methods and set the headers there. Another way to achieve the same thing would be to write an interceptor, which modifies each request: theinfogrid.com/tech/developers/angular/…
– mchl18
Jan 2 at 15:18
I'll look into interceptor.. Thanks for your time. I'll accept your answer :)
– Apogee
Jan 3 at 2:32
add a comment |
For starters, Angulars Http Module is based on Observables which are widely used within Angular and thus Ionic themselves. The Ionic Http Module instead is based on Promises, which itself is totally fine if you want to use them.
Since this is an Ionic Native Module this also means that the app is not going to make these requests using either the underlying Java (Android) or Objective-C (iOS) function instead of a Javascript function (Please anybody correct me if I am wrong here)
However the main advantages are listed on the Github Repo of the Ionic Http Module:
- Background threading - all requests are done in a background thread.
- Handling of HTTP code 401 - read more at Issue CB-2415.
- SSL Pinning - read more at LumberBlog.
The first point seems to be the most appealing, since it is a feature which is not merely solving a problem but adding functionality.
I cannot tell exactly how big of an advantage it is to run these in a background thread but I also doubt that this will have a big impact unless your app is very network-expensive.
So Ionics native module solves exactly these problems which apparently come with using plain Javascript functions for making http requests from a containered mobile app.
I would say that the Ionic Native solution should only be used in case you encounter any of the above problems.
If not, you would simply add a new dependency which uses another paradigm (promises) than probably any tutorial on Angular which you can find. You simply reduce complexity and bundle size by not using it if it isn't needed.
Angular comes bundled with the Http Module and it is well maintained, also you will find much more help online for this package.
For starters, Angulars Http Module is based on Observables which are widely used within Angular and thus Ionic themselves. The Ionic Http Module instead is based on Promises, which itself is totally fine if you want to use them.
Since this is an Ionic Native Module this also means that the app is not going to make these requests using either the underlying Java (Android) or Objective-C (iOS) function instead of a Javascript function (Please anybody correct me if I am wrong here)
However the main advantages are listed on the Github Repo of the Ionic Http Module:
- Background threading - all requests are done in a background thread.
- Handling of HTTP code 401 - read more at Issue CB-2415.
- SSL Pinning - read more at LumberBlog.
The first point seems to be the most appealing, since it is a feature which is not merely solving a problem but adding functionality.
I cannot tell exactly how big of an advantage it is to run these in a background thread but I also doubt that this will have a big impact unless your app is very network-expensive.
So Ionics native module solves exactly these problems which apparently come with using plain Javascript functions for making http requests from a containered mobile app.
I would say that the Ionic Native solution should only be used in case you encounter any of the above problems.
If not, you would simply add a new dependency which uses another paradigm (promises) than probably any tutorial on Angular which you can find. You simply reduce complexity and bundle size by not using it if it isn't needed.
Angular comes bundled with the Http Module and it is well maintained, also you will find much more help online for this package.
edited Jan 2 at 9:51
answered Jan 2 at 9:43


mchl18mchl18
924314
924314
Greatly explained. By your explanation I feel I should go with angular httpClient. But the reason I got attracted towards ionic native http is, "setHeader(host, header, value)" >> Set a header for all future requests. Takes a hostname, a header and a value. Is something similar available in angular httpClient ?
– Apogee
Jan 2 at 10:49
Sadly I believe that this is not provided by the Angular module itself. However it is really easy to achieve the same thing. One way is to go ahead and write your own request-service which wraps the angular http methods and set the headers there. Another way to achieve the same thing would be to write an interceptor, which modifies each request: theinfogrid.com/tech/developers/angular/…
– mchl18
Jan 2 at 15:18
I'll look into interceptor.. Thanks for your time. I'll accept your answer :)
– Apogee
Jan 3 at 2:32
add a comment |
Greatly explained. By your explanation I feel I should go with angular httpClient. But the reason I got attracted towards ionic native http is, "setHeader(host, header, value)" >> Set a header for all future requests. Takes a hostname, a header and a value. Is something similar available in angular httpClient ?
– Apogee
Jan 2 at 10:49
Sadly I believe that this is not provided by the Angular module itself. However it is really easy to achieve the same thing. One way is to go ahead and write your own request-service which wraps the angular http methods and set the headers there. Another way to achieve the same thing would be to write an interceptor, which modifies each request: theinfogrid.com/tech/developers/angular/…
– mchl18
Jan 2 at 15:18
I'll look into interceptor.. Thanks for your time. I'll accept your answer :)
– Apogee
Jan 3 at 2:32
Greatly explained. By your explanation I feel I should go with angular httpClient. But the reason I got attracted towards ionic native http is, "setHeader(host, header, value)" >> Set a header for all future requests. Takes a hostname, a header and a value. Is something similar available in angular httpClient ?
– Apogee
Jan 2 at 10:49
Greatly explained. By your explanation I feel I should go with angular httpClient. But the reason I got attracted towards ionic native http is, "setHeader(host, header, value)" >> Set a header for all future requests. Takes a hostname, a header and a value. Is something similar available in angular httpClient ?
– Apogee
Jan 2 at 10:49
Sadly I believe that this is not provided by the Angular module itself. However it is really easy to achieve the same thing. One way is to go ahead and write your own request-service which wraps the angular http methods and set the headers there. Another way to achieve the same thing would be to write an interceptor, which modifies each request: theinfogrid.com/tech/developers/angular/…
– mchl18
Jan 2 at 15:18
Sadly I believe that this is not provided by the Angular module itself. However it is really easy to achieve the same thing. One way is to go ahead and write your own request-service which wraps the angular http methods and set the headers there. Another way to achieve the same thing would be to write an interceptor, which modifies each request: theinfogrid.com/tech/developers/angular/…
– mchl18
Jan 2 at 15:18
I'll look into interceptor.. Thanks for your time. I'll accept your answer :)
– Apogee
Jan 3 at 2:32
I'll look into interceptor.. Thanks for your time. I'll accept your answer :)
– Apogee
Jan 3 at 2:32
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003077%2fcordova-plugin-advanced-http-vs-angular-common-http%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
HttpClient will send http requests from webview without using native http calls. It may produce CORS issue if your api server is not configured to serve cross origin requests.
– Omurbek Kadyrbekov
Jan 2 at 8:08