Ionic: Cant make HTTP(S) calls from DevApp - Error is [object Object]
up vote
0
down vote
favorite
I am trying to make HTTP and HTTPS calls from my Ionic 3 App running in Ionic DevApp on my Android phone. I am running ionic serve -c and running the app in both Chrome browser on my PC and in DevApp. HTTP calls from DevApp always return an error with the data [object Object]
Chrome wasn’t working until I enabled CORS on my server by changing the config of my .NET WebAPI project. Now calls work fine from Chrome, but not from DevApp.
I have tried both HttpClient from ‘@angular/common/http’ and HTTP from ‘@ionic-native/http’ (the second of which isn’t usable in Chrome being a Cordova component), but neither work within the DevApp. These are the methods:
private getString1(httpClient: HttpClient, callbackUrl : string) : Promise<any> {
return new Promise(resolve => {
httpClient.get(callbackUrl).subscribe(data => {
console.log(data); // Chrome gets string from server
resolve(data);
}, err => {
console.log("Error - ", err); // DevApp gets [object Object]
});
});
}
private getString2(http : HTTP, callbackUrl : string) : void {
this.http.get(callbackUrl, {}, {}).then(data => {
console.log(data); // Chrome gets string from server
}).catch(error => {
console.log("Error - " + error); // DevApp gets [object Object]
});
}
Finally I have added this to ionic.config.json to create a proxy as is suggested in the documentation:
{
"name": "xxxxx",
"integrations": {
"cordova": {}
},
"type": "ionic-angular",
"proxies": [
{ "path": "/api/auth",
"proxyUrl": "http://example.com/api/auth" }]
}
and changed the HTTP addresses to localhost:8100…to no avail.
I did briefly get things working by setting up Fiddler on my PC as a proxy and routing though there...but then it stopped working and I then felt I had imagined it.
I am pretty much out of ideas at this point. I need to use DevApp for development rather than Chrome as I need @ionic-native/in-app-browser to implement oAuth 2.0 workflow. I can probably just develop in Chrome and work around this somehow, but I am also worried this isn’t just a DevApp issue and wont work when I publish the app.
There is also the option of looking at Xamarin or biting the bullet and going native.
ionic-framework cors ionic3
add a comment |
up vote
0
down vote
favorite
I am trying to make HTTP and HTTPS calls from my Ionic 3 App running in Ionic DevApp on my Android phone. I am running ionic serve -c and running the app in both Chrome browser on my PC and in DevApp. HTTP calls from DevApp always return an error with the data [object Object]
Chrome wasn’t working until I enabled CORS on my server by changing the config of my .NET WebAPI project. Now calls work fine from Chrome, but not from DevApp.
I have tried both HttpClient from ‘@angular/common/http’ and HTTP from ‘@ionic-native/http’ (the second of which isn’t usable in Chrome being a Cordova component), but neither work within the DevApp. These are the methods:
private getString1(httpClient: HttpClient, callbackUrl : string) : Promise<any> {
return new Promise(resolve => {
httpClient.get(callbackUrl).subscribe(data => {
console.log(data); // Chrome gets string from server
resolve(data);
}, err => {
console.log("Error - ", err); // DevApp gets [object Object]
});
});
}
private getString2(http : HTTP, callbackUrl : string) : void {
this.http.get(callbackUrl, {}, {}).then(data => {
console.log(data); // Chrome gets string from server
}).catch(error => {
console.log("Error - " + error); // DevApp gets [object Object]
});
}
Finally I have added this to ionic.config.json to create a proxy as is suggested in the documentation:
{
"name": "xxxxx",
"integrations": {
"cordova": {}
},
"type": "ionic-angular",
"proxies": [
{ "path": "/api/auth",
"proxyUrl": "http://example.com/api/auth" }]
}
and changed the HTTP addresses to localhost:8100…to no avail.
I did briefly get things working by setting up Fiddler on my PC as a proxy and routing though there...but then it stopped working and I then felt I had imagined it.
I am pretty much out of ideas at this point. I need to use DevApp for development rather than Chrome as I need @ionic-native/in-app-browser to implement oAuth 2.0 workflow. I can probably just develop in Chrome and work around this somehow, but I am also worried this isn’t just a DevApp issue and wont work when I publish the app.
There is also the option of looking at Xamarin or biting the bullet and going native.
ionic-framework cors ionic3
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to make HTTP and HTTPS calls from my Ionic 3 App running in Ionic DevApp on my Android phone. I am running ionic serve -c and running the app in both Chrome browser on my PC and in DevApp. HTTP calls from DevApp always return an error with the data [object Object]
Chrome wasn’t working until I enabled CORS on my server by changing the config of my .NET WebAPI project. Now calls work fine from Chrome, but not from DevApp.
I have tried both HttpClient from ‘@angular/common/http’ and HTTP from ‘@ionic-native/http’ (the second of which isn’t usable in Chrome being a Cordova component), but neither work within the DevApp. These are the methods:
private getString1(httpClient: HttpClient, callbackUrl : string) : Promise<any> {
return new Promise(resolve => {
httpClient.get(callbackUrl).subscribe(data => {
console.log(data); // Chrome gets string from server
resolve(data);
}, err => {
console.log("Error - ", err); // DevApp gets [object Object]
});
});
}
private getString2(http : HTTP, callbackUrl : string) : void {
this.http.get(callbackUrl, {}, {}).then(data => {
console.log(data); // Chrome gets string from server
}).catch(error => {
console.log("Error - " + error); // DevApp gets [object Object]
});
}
Finally I have added this to ionic.config.json to create a proxy as is suggested in the documentation:
{
"name": "xxxxx",
"integrations": {
"cordova": {}
},
"type": "ionic-angular",
"proxies": [
{ "path": "/api/auth",
"proxyUrl": "http://example.com/api/auth" }]
}
and changed the HTTP addresses to localhost:8100…to no avail.
I did briefly get things working by setting up Fiddler on my PC as a proxy and routing though there...but then it stopped working and I then felt I had imagined it.
I am pretty much out of ideas at this point. I need to use DevApp for development rather than Chrome as I need @ionic-native/in-app-browser to implement oAuth 2.0 workflow. I can probably just develop in Chrome and work around this somehow, but I am also worried this isn’t just a DevApp issue and wont work when I publish the app.
There is also the option of looking at Xamarin or biting the bullet and going native.
ionic-framework cors ionic3
I am trying to make HTTP and HTTPS calls from my Ionic 3 App running in Ionic DevApp on my Android phone. I am running ionic serve -c and running the app in both Chrome browser on my PC and in DevApp. HTTP calls from DevApp always return an error with the data [object Object]
Chrome wasn’t working until I enabled CORS on my server by changing the config of my .NET WebAPI project. Now calls work fine from Chrome, but not from DevApp.
I have tried both HttpClient from ‘@angular/common/http’ and HTTP from ‘@ionic-native/http’ (the second of which isn’t usable in Chrome being a Cordova component), but neither work within the DevApp. These are the methods:
private getString1(httpClient: HttpClient, callbackUrl : string) : Promise<any> {
return new Promise(resolve => {
httpClient.get(callbackUrl).subscribe(data => {
console.log(data); // Chrome gets string from server
resolve(data);
}, err => {
console.log("Error - ", err); // DevApp gets [object Object]
});
});
}
private getString2(http : HTTP, callbackUrl : string) : void {
this.http.get(callbackUrl, {}, {}).then(data => {
console.log(data); // Chrome gets string from server
}).catch(error => {
console.log("Error - " + error); // DevApp gets [object Object]
});
}
Finally I have added this to ionic.config.json to create a proxy as is suggested in the documentation:
{
"name": "xxxxx",
"integrations": {
"cordova": {}
},
"type": "ionic-angular",
"proxies": [
{ "path": "/api/auth",
"proxyUrl": "http://example.com/api/auth" }]
}
and changed the HTTP addresses to localhost:8100…to no avail.
I did briefly get things working by setting up Fiddler on my PC as a proxy and routing though there...but then it stopped working and I then felt I had imagined it.
I am pretty much out of ideas at this point. I need to use DevApp for development rather than Chrome as I need @ionic-native/in-app-browser to implement oAuth 2.0 workflow. I can probably just develop in Chrome and work around this somehow, but I am also worried this isn’t just a DevApp issue and wont work when I publish the app.
There is also the option of looking at Xamarin or biting the bullet and going native.
ionic-framework cors ionic3
ionic-framework cors ionic3
asked Nov 19 at 11:55
Mr. Lane
12
12
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53374116%2fionic-cant-make-https-calls-from-devapp-error-is-object-object%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