I am currently using Angular CLI: 6.0.8
and have implemented the service shown below. However, my code editor's linter keeps showing an error message that reads:
[ts] Property 'map' does not exist on type 'Object'.
any
The error specifically points to the return statement containing the .map()
function:
............
return bills.map((bill) => new Bill(bill));
.................
service
// Imported HttpClient for making HTTP requests.
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Bill } from '../../models/bill'
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
// Convert this TypeScript class into an injectable service.
@Injectable()
export class BillServiceProvider {
// Define your back-end API address.
baseUrl:string = "http://localhost:8000/api/properties";
constructor(private http: HttpClient) {}
// Sending a GET request to /bills
public getBills(): Observable<Bill[]> {
return this.http
.get(this.baseUrl + '/bills')
.map(bills => {
return bills.map((bill) => new Bill(bill));
})
.catch((err)=>{
console.error(err);
})
}