Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PageIterator does not work on empty collections #129

Closed
ChristianBoehlke opened this issue Nov 28, 2018 · 2 comments
Closed

PageIterator does not work on empty collections #129

ChristianBoehlke opened this issue Nov 28, 2018 · 2 comments

Comments

@ChristianBoehlke
Copy link

Hello,

We are using this library and the PageIterator to iterate over multiple pages that are returned from GET /v1.0/me/calendarView/delta.

If the calendar is empty, the response looks like this:

/v1.0/me/calendarView/delta?startDateTime=[omitted]&endDateTime=[omitted]
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(event)",
  "@odata.nextLink": "https: //graph.microsoft.com/v1.0/me/calendarview/delta?$skiptoken=[omitted]",
  "value": []
}

As you can see, values is empty but the response does not contain a deltaLink but a nextLink. Only on the second page (the second request) the response contains a deltaLink:

/v1.0/me/calendarview/delta?$skiptoken=[omitted]
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(event)",
  "@odata.deltaLink": "https://graph.microsoft.com/v1.0/me/calendarview/delta?$deltatoken=[omitted]",
  "value": []
}

Unfortunately, the PageIterator stops iterating if the response has no values and it does not fetch the second page:

if (self.collection === undefined || self.collection.length === 0) {
return false;
}

Is there another way to make the PageIterator work with empty collections?

Would it make more sense to keep fetching pages until the first deltaLink is returned? I'm happy to contribute a PR for that.

@muthurathinam
Copy link
Contributor

@ChristianBoehlke Thanks for reporting this issue. Yes its a valid to keep fetching until the deltaLink is returned in this case. It will be awesome if you contribute with a PR for this.

@muthurathinam
Copy link
Contributor

Fixed in v1.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants