I am trying to setup a service on Angular version 7 but I'm having an issue on res.json()
which throws the error Property 'json' does not exist on type 'Object'
. This is my service's code:
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from "rxjs";
import 'rxjs/add/operator/map';
import { map } from 'rxjs/operators';
import {
SVCParameters,
SVCResult
} from "./types";
const SERVER_URL: string = 'api/';
@Injectable()
export class IrisService {
constructor(private http: HttpClient) {
}
public trainModel(svcParameters: SVCParameters): Observable<SVCResult> {
return this.http.post(`${SERVER_URL}train`, svcParameters).pipe(map(res => res.json()));
}
}
The following is my types.ts code:
export class SVCParameters {
C: number = 2.0;
}
export class SVCResult{
accuracy: number;
}