I can not figure it out why i got this error
getByURL(url: string): any {
return this.apiService.get(url).pipe(map(data => data));
}
getByNextPage(): Observable<any> {
const url = 'url';
this.getByURL(url).pipe(
expand(data => {
console.log(data);
})
);
}
I got this error at line that has expand(data => ... . I want to use expand() so i can recursive the call for the next api.
Type 'void' is not assignable to type 'ObservableInput<{}>'
Any hint would be really appreciate. Thanks
I can not figure it out why i got this error
getByURL(url: string): any {
return this.apiService.get(url).pipe(map(data => data));
}
getByNextPage(): Observable<any> {
const url = 'url';
this.getByURL(url).pipe(
expand(data => {
console.log(data);
})
);
}
I got this error at line that has expand(data => ... . I want to use expand() so i can recursive the call for the next api.
Type 'void' is not assignable to type 'ObservableInput<{}>'
Any hint would be really appreciate. Thanks
Share asked May 31, 2019 at 0:32 daniel8xdaniel8x 1,0804 gold badges20 silver badges38 bronze badges 2- Try adding a return statement to getByNextPage() b/c is not returning anything, – artemisian Commented May 31, 2019 at 0:53
- @artemisian Thanks. stackoverflow./questions/56398014/…. I have another question here which related to this one. Not sure if you can take a quick look. I got stuck there. thanks – daniel8x Commented May 31, 2019 at 15:59
3 Answers
Reset to default 2You need check data type of data variable and return data in your method.
getByNextPage(): Observable<any> {
const url = 'url';
this.getByURL(url).pipe(
expand(data => {
console.log(data);
return data;
})
);
}
expand(data => {
console.log(data);
})
Your function does not return anything, hence the void. You need to return an observable.
That is because you are using expand() operator badly. If you check documentation, the expand() operator has to return an Observable and you are not returning nothing.
Even though you return "data" variable the error will still persist because that rule.
Check this documentation
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744930678a4601716.html
评论列表(0条)