Skip to content

Commit bed3bb4

Browse files
committed
fix paging id in devices script
1 parent dc7f4da commit bed3bb4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

plugins/NinjaOne/v1/dataStreams/scripts/devices.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,18 @@ result = {
5050
metadata: (data && data.metadata) ? { ...data.metadata } : {}
5151
};
5252

53+
// Capture next_page_token from root if present (some endpoints put it there)
54+
if (data && data.next_page_token) {
55+
result.metadata.next_page_token = data.next_page_token;
56+
}
57+
58+
// Capture cursor from root if present (used by some endpoints)
59+
if (data && data.cursor) {
60+
result.metadata.cursor = data.cursor;
61+
}
62+
5363
// If the response was a flat array, we can still support paging by providing a next_page_token
54-
// if it's not already in the metadata.
64+
// based on the last item's ID (which is what NinjaOne often expects in 'after' param)
5565
if (Array.isArray(data) && !result.metadata.next_page_token) {
5666
result.metadata.next_page_token = processedItems.length > 0 ? processedItems[processedItems.length - 1].id : null;
5767
}

0 commit comments

Comments
 (0)