Can't Login through API IONIC 3

Hi there,

I am new to IONIC and I am trying to build a simple application with a login through my API (JWAUTH Laravel).

I was following some tutorials and I can’t understand where my mistake is, when I try to login the code jump right to the error message.

Any ideas why ? Thanks.


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

let apiUrl = "";


export class AuthServiceProvider {

postData(credentials, type) {
      return new Promise((resolve, reject) => {
        let headers = new Headers(); + type, JSON.stringify(credentials), {headers: headers})
          .subscribe(res => {
          }, (err) => {




import { AuthServiceProvider } from '../../providers/auth-service/auth-service';


export class LoginPage {

responseData : any;
  userData = {"email":"", "password":""};

   constructor(public navCtrl: NavController, public menuCtrl: MenuController, public authServiceProvider : AuthServiceProvider) {
    this.menuCtrl.enable(false, 'myMenu');

    this.authServiceProvider.postData(this.userData, "auth/login").then((result) =>{
      this.responseData = result;
      localStorage.setItem('userData', JSON.stringify(this.responseData));
    }, (err) => {
      //Connection failed message


Any tutorial that recommends “new Promise()” when dealing with Angular HttpClient is braindead and should not be followed. In addition, you don’t need to be making headers, stringifying anything, or calling json() on responses. I would suggest starting over following the idioms documented in here.

If the problem still persists, with issues like this, it’s important to know where you are running the app and where you are running the server. is where the app is running, so if that’s a device things aren’t going to work unless there’s a proxy running on there.

Thanks I will take a look.

The app and the server ar both local.

Hi, on postData() try use “resolve(res)” instead of “resolve(res.json())”