将observable <object>转换为observable <task []>

时间:2018-03-07 17:36:44

标签: javascript node.js angular typescript

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对象的接口。

1 个答案:

答案 0 :(得分:2)

假设您正在使用HttpClient:

return this.http.get<Task[]>('http://localhost:3000/tasks');