Data is null


#1

I am getting an error while i do ionic serve i didn’t used to get it. My app used to connect to database alright. But know i am getting a data is null error . Why is that?


#2

this is what i am getting on console

auth-service.ts:10 Hello AuthService Provider

/PHP-Slim-Restful1/api/friendsList:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
app.component.ts:87 No connection

/PHP-Slim-Restful1/api/groupsList:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
app.component.ts:104 No connection

/PHP-Slim-Restful1/api/pressList:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
app.component.ts:121 No connection

/PHP-Slim-Restful1/api/newsFeed:1 Failed to load resource: net::ERR_CONNECTION_REFUSED

this is my auth-service.ts

import { Injectable } from '@angular/core';
import { Http, Headers } from '@angular/http';
import 'rxjs/add/operator/map';

let apiUrl = "http://localhost/PHP-Slim-Restful1/api/";

@Injectable()
export class AuthService {
  constructor(public http: Http) {
    console.log('Hello AuthService Provider');
  }
 
  postData(credentials, type) {
      return new Promise((resolve, reject) => {

      let headers = new Headers();
      this.http.post(apiUrl+type, JSON.stringify(credentials), {headers: headers}).
      subscribe(res =>{
        resolve(res.json());
      }, (err) =>{
        reject(err);
      });
      
    });

  }

}


#3

Based on the :ERR_CONNECTION_REFUSED message, it seems your web/http server is down.
As you point it to localhost, try to check if the service behind port 80 is up.
You can test using :

telnet localhost 80
And check for a connection prompt.
I assume, it will fail as it shows in the error message.