Returning Array[] with Obsevable

Asked

Viewed 26 times

0

I’m developing an Angular 2 application and in my service I’m returning one Observable<Pessoa[]> but when returning http with my get it runs the following error. Type 'Observable<HttpResponse<Object>>' is not assignable to type 'Observable<Pessoa[]>'. Type 'HttpResponse<Object>' is missing the following properties from type 'Pessoa[]': length, pop, push, concat, and 26 more.

Personal service

 /**CONSULTA TODAS AS PESSOAS CADASTRADAS */
getPessoas(): Observable<Pessoa[]> {
return this.http.get(this.baseUrlService, { observe: 'response' });
}
  • pq vc need to observe Sponse??

1 answer

0

If you have used Httpclient do so:

getPessoas(): Observable<Pessoa[]> {
return this.http.get<Pessoa[]>(this.baseUrlService);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.