HTTP ERROR Response on device

Hi all,
I am facing an issue, app was working fine on browser, But in device it is giving error

and on device also in ionic 3 it is working fine, in ionic v4 only it is giving error.
HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: “Unknown Error”, url: “http://111.111.11.111:8080/tetra/services/global/check/111/1000/12345”, ok: false, …}.

So please help me.
My ionic info is
Ionic:

Ionic CLI : 5.4.8 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.11.7
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.1.1

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 5 other plugins)

Utility:

cordova-res : 0.8.1
native-run : 0.2.8 (update available: 0.3.0)

System:

Android SDK Tools : 26.1.1 (/Users/sathguru/Library/Android/sdk)
ios-deploy : 1.9.4
NodeJS : v10.13.0 (/usr/local/bin/node)
npm : 6.13.2
OS : macOS High Sierra
Xcode : Xcode 10.1 Build version 10B61

login functionality is

this.http.get(url,{}).subscribe(data=>{
      console.log(data);
      this.jsonData=data
      console.log("data is " + this.jsonData.response);
      var result = this.jsonData.response;

      if (result == "success") {
      this.closeLoader();
       this.router.navigate(['home'])  ;  
   
      }
      else {
     
       this.closeLoader();
       
      }
              },error=>{
                console.log("error is ");
                console.log(error);
                this.closeLoader();
              });

my config.xml file I added this also

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

Even though not working. help me please.

Sorry to hear that. either cross origin issues or you device should be connect with your local wifi network . Sorry for my poor english.

Please see if the problem persists even when using HTTPS endpoints.

Try using SSL Certificate, i haved this error when i don’t use SSL.

What is SSl, and how to use it.

Its Ok . Thanks for the reply. I connected to my local wifi only. I tried in some other devices too. But issue is same.
How to solve cross origin issue?

Are you using Http (@angular/http) or HttpClient (@angular/common/http)?

The former is no longer the way to do it

Hi am using, HttpClient only.

You can try like this .
add_header 'Access-Control-Allow-Origin'

Ok. Can you guide me how to add this header. Please

Hi @Harikag
could you provide APK file ? and specify in which you have a problem ?
and is that issue in ios or android ?

I have issue for android

hello reply please, How to add this header

Sorry for late reply. actually am in office that’ why am late to reply. just add this header to your .htacess or api server end

It’s ok.
Sorry for asking like this. For any example, please.

try like this

<IfModule mod_headers.c>
  Header set Access-Control-Allow-Origin "*"
</IfModule>

See I am adding headers like this.

var url = this.ip_port+"tetra/services/global/check/" + id + "/" + un + "/" + pwd;
      
        console.log("url is " + url);
        let headers = new HttpHeaders({
            'Content-Type': 'text/plain',
        });

        let options = { headers: headers };
        this.http.get(url,options).subscribe(data=>{
            console.log(data);
            return data;
                    });

So where should I add your above one. am not understanding.
Or should I need to add in config.xml file

you can use this plugin to make your api call rather than angular HTTP or HttpClient

I am unable to understand what you are saying. can you suggest to me clearly. Thanks in advance.

Did you ever test this?