Reputation: 111
I'm trying to type the return of my request however I'm getting the following error:
Type 'Observable' is not assignable to type 'Observable'. Type 'ArrayBuffer' is missing the following properties from type 'AccountModel[]': length, pop, push, concat, and 25 more
I request is as follows:
getAccounts(): Observable<AccountModel[]>
{
return this.http.get(`${this._configShared.getApiUrl()}`, this.httpOptions);
}
Where am I going wrong?
Thanks in advance...
I did the following and it also did not work:
getAccounts(): Observable<AccountModel[]>
{
return this.http.get<AccountModel[]>(`${this._configShared.getApiUrl()}`, this.httpOptions);
}
error:
Type 'Observable>' is not assignable to type 'Observable'. Type 'HttpEvent' is not assignable to type 'AccountModel[]'. Type 'HttpSentEvent' is missing the following properties from type 'AccountModel[]': length, pop, push, concat, and 26 more.
Upvotes: 1
Views: 1054
Reputation: 11474
Change
return this.http.get(`${this._configShared.getApiUrl()}`, this.httpOptions);
to
return this.http.get<AccountModel[]>(`${this._configShared.getApiUrl()}`, this.httpOptions);
Upvotes: 5