I've been working with a app that pick up the events from a calendar and show them as a list in a modern page.
The code is working almost fine. Its show the comming events from the calendar but the problem is that in the calendar there is a lot of events, almost 40 events and the app is showing all the almost 40 events. As you can imaginate the list is very long.
I am trying to set a kind of counter so the app shows just 10 comming events but I can't find the way.
This is the render method that get the events from an array called ISPList:
My first idea was to set a $top=10 in the rest request but doing in that way the list shows the first 10 events from the first event in the calendar, which is in april and all other comming event get lost.
Then I tried to set a for-loop inside the if-sats but it just print x-times the same event.