Answer the question
In order to leave comments, you need to log in
How to get rid of the error "Property 'data' does not exist on type 'Subscribers[]'"?
Hello.
There is json
{
"count":"404875",
"data":[{
...
}]
}
getSubscribers(page:Number, pageSize:Number): Observable<Subscribers[]> {
return this.http.get(this._subscribers +'/'+page+'/'+pageSize)
.map(this.extractData)
.catch(this.handleError)
}
private extractData(res: Response) {
let body = res.json();
return body;
}
getSubscribers(page = 1){
this.subscribersService.getSubscribers(page, this.pageSize)
.subscribe(
data => {
this.subscribers = data.data,
this.count = data.count,
this.p = page
},
error => this.errorMessage = <any>error
)
}
app/components/subscribers/index.component.ts(32,45): error TS2339: Property 'data' does not exist on type 'Subscribers[]'.
app/components/subscribers/index.component.ts(33,39): error TS2339: Property 'count' does not exist on type 'Subscribers[]'.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question