I have this piece of jQuery
code that works fine cross-origin:
jQuery.ajax({
url: "http://example.appspot.com/rest/app",
type: "POST",
dataType: 'jsonp',
jsonp: 'jsonp',
data: JSON.stringify({"foo":"bar"}),
contentType: "application/json; charset=utf-8",
success: function (response) {
console.log("success");
},
error: function (response) {
console.log("failed");
}
});
I’m a novice to ionic2
. I’m trying to convert this to Angular2/ionic2
code but there is no success.
Is there any similar function for jquery.ajax
in angular2/ionic2
.
I’m not getting how to deal with the above code in angular2/ionic2
using this.http.get
or this.http.post
or this.jsonp.request
.
Any help appreciated.
Thanks in advance.