I keep receiving a compilation error:
TS2339: Property 'json' does not exist on type 'Object'
when attempting to map JSON onto a complex object Model.SearchResult.RootObject
. The error occurs within the res.json()
method of the following service:
import { Injectable } from '@angular/core';
import { ResultPrice } from '../models/result-prices.model';
import { BaseService } from '../shared-components/base-service/base.service';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import * as Model from '../models/results.model';
import { HttpClient } from '@angular/common/http';
import 'rxjs/add/operator/map';
@Injectable()
export class SearchResultService {
private apiUrl = 'http://someurl/api/SearchResult/';
constructor(public http: HttpClient ) {
}
getSearchResultTable(hash: number): Observable<Model.SearchResult.RootObject> {
let tmp = this.http.get('http://someurl/api/SearchResult/123')
.map(res => {
return res.json().results.map(item => {
return new Model.SearchResult.RootObject();
});
});
return tmp;
}
}
Does the Observable
interface actually contain a json
property? Could it be that I missed importing something?