instagram-private-api icon indicating copy to clipboard operation
instagram-private-api copied to clipboard

How to get a specific amount of data from a Feed items$ (limit)

Open StevenBLR opened this issue 3 years ago • 0 comments

i'm trying to get a specific amount of posts from feeds ( liked / saved / timeline ). So I used the subscribe method on items$ (rxjs Observable)

ig.feed().liked().items$.subscribe(async (Posts: any[]) => { //Store datas from posts } );

It loads streams of data from those feeds (until no more data is available). But I want to have more control over this stream of data by setting a limit with a specific amount of data to get.

I looked on rxjs documentation and I found this pipe(take(limit)) which is supposed to set a limit on our subscribe method.

So I tried to apply it to my code with this line method.items$.pipe(take(5)).subscribe(async (Posts: any[]) => { //Store datas from posts } ); But I have this error

Argument of type 'MonoTypeOperatorFunction' is not assignable to parameter of type 'OperatorFunction<any[], unknown>'. Types of parameters 'source' and 'source' are incompatible. Type 'Observable<any[]>' is not assignable to type 'Observable'. The types of 'source.operator.call' are incompatible between these types. ... More

Any ideas on how I can overcome this problem ? ( Maybe with another method )

StevenBLR avatar Nov 10 '21 22:11 StevenBLR