Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49253

HttpErrorResponse and cross origin issue

$
0
0

@lsantaniello wrote:

Hi friends,
I deployed my ionic app on my iphone but I receive this error when I invoke the REST API:

{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":null,"ok":false,"name":"HttpErrorResponse","message":"Http failure response for (unknown url): 0 Unknown Error","error":{"isTrusted":true}}

During development into browser, I used CORS in order to disable cross origin control.

In my config.xml file I have:

    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-navigation href="*" />

My example code:

this.reqOpts = {
      headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Access-Control-Allow-Origin': '*'
      },
      params: new HttpParams()
    };
login(username, password) {
    var url = ...;
    return new Promise(resolve => {
      this.http.get(url, this.reqOpts).subscribe(
        data => { 
              resolve(data); 
        }, 
        err => {
               ...
        }
      );
    });
  }

Help me please

Luca

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49253

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>