Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70443

Ionic 4: HttpClient is giving me a “http error response 0 unknown error”

$
0
0

@feliperiverot wrote:

I am working with Ionic 4 developing and hybrid app. I am trying to consume an API URL. I am calling the API with the below code.

import { HttpHeaders, HttpErrorResponse, HttpClient  } from '@angular/common/http';

  constructor(private http: HttpClient, private androidPermissions: AndroidPermissions, private uid: Uid, private device: Device,  public platform: Platform, public formBuilder: FormBuilder, private router: Router, private nativeStorage: NativeStorage,private fb: Facebook,   private googlePlus:GooglePlus ) {


  platform.ready().then(() => {
      this.onDeviceReady();
    });


  }

    let urlSearchParams = new URLSearchParams();
urlSearchParams.append('brand', this.myManufacturer );
urlSearchParams.append('model',  this.myModel);
urlSearchParams.append('androidid', this.myUuidt);
urlSearchParams.append('serialsim', this.myUuidt);
urlSearchParams.append('imei', this.myIMEI);    

     this.httpOptions = {
    headers: new HttpHeaders(
    {
      'Content-Type': 'application/json',
      'Authorization': this.tobas64string
    })
  }



    this.http.post("some url", urlSearchParams.toString(),  this.httpOptions).subscribe(
        data  => {
        alert(JSON.stringify(data));
        },
        error  => {

        alert(JSON.stringify(error));

        }
    );

And I get this result:

enter image description here

I am testing in my cell phone, is android 9 model.

Any ideas why this is happening?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70443

Trending Articles



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