HTTP post request doesn't work on my Device


#1

Hello guys,
I have a problem with my HTTP post Request. It work on my browser ( with CORS issues disabled ) but on my iPhone, not working.

In my xcode console i have this : " Response with status: 0 for URL: null " when i try to log.

This is my login services.

// Core components
import { Injectable }   from '@angular/core';
import { Http }         from '@angular/http';

// RxJS
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/map';

// Models

import { LoginModel } from "../models/login.model";

@Injectable()
export class LoginServices {

  private baseUrl: string = '<MY EXTERIOR URL>';

  constructor(private http: Http) {

  }

  public fetchedLogin(email,password): any {
    const url = `${this.baseUrl}`;

    return this.http.post(url,
      {
        email : email,
        password : password
      })
      .toPromise()
      .then( response => response.json() as LoginModel)
      .catch( error => console.log("Error :" + error +" "))

  }

I work with an exterior API, not in local.

Idk if we need to set some setting for http.post communication (in config or something like that).

Thanks for ur help !

(srry for my bad english x’) )


#2

I ran into this same issue a few days ago, and I found that for iOS you should use the ionic native http plugin, since using the angular http plugin has issues with the WKWebview plugin. The link for my solution is below.

My thread about this issue


#3

Thanks you !

Work perfectly on my device.