return this.http.get('http://localhost:3000/tasks');
//Returns Observable<Object>, but I want it to return or convert into Observable<Task[]>.
Task只是一个与/ tasks端点匹配JSON对象的接口。
答案 0 :(得分:2)
假设您正在使用HttpClient:
return this.http.get<Task[]>('http://localhost:3000/tasks');