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.










share|improve this question


























    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.










    share|improve this question
























      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.










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 at 11:55









      Mr. Lane

      12




      12





























          active

          oldest

          votes











          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',
          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
          });


          }
          });














          draft saved

          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin