I am trying to write a service for deleting from my external db and I keep seeing this error:
The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'Response' is not a valid type argument because it is not a supertype of candidate 'Response'. Types of property 'type' are incompatible. Type 'string' is not assignable to type 'ResponseType'.
^ and this error highlights the line:
return this.http.delete(`${this.base_url}/${id}`)
Here is the service:
import { Injectable } from '@angular/core';
import { CheckIn } from './check-in';
import { Headers, RequestOptions, Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
@Injectable()
export class CheckInService {
private base_url = "http://localhost:3000/";
constructor (private http: Http) {}
delete(id:string): Observable<CheckIn[]> {
return this.http.delete(`${this.base_url}/${id}`)
.map((res:Response) => res.json()) .json() on the response to return data
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}
}
What am I doing wrong?