As you used {}, it needs an explicit return from function. Therefore you need to return the function <Payitem[]>response.json()from map.
getPayItems():Observable<Payitem[]>{
let actionUrl = this.url + "/GetPayItem";
return this._http.get(actionUrl, { headers: this.headers })
.map((response: Response) => {
console.log(<Payitem[]>response.json()); //This logs the Object
return <Payitem[]>response.json() ;
})
.catch(this.handleError);
}
Otherwise, there will be a shorthand syntax below
getPayItems():Observable<Payitem[]>{
let actionUrl = `${this.url}/GetPayItem`;
return this._http.get(actionUrl, { headers: this.headers })
.map((response: Response) => <Payitem[]>response.json())
.catch(this.handleError);
}
source
share