Skip to content

Commit a36d609

Browse files
authored
Added paginated traversing through content items in capture.js script. (#1017)
1 parent 4c31e0a commit a36d609

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts.v2/capture.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,21 @@ async function getContentTypes() {
1414
}
1515

1616
async function getContentItems(contentType) {
17-
const data = await request("GET", `https://${managementApiEndpoint}/subscriptions/00000/resourceGroups/00000/providers/Microsoft.ApiManagement/service/00000/contentTypes/${contentType}/contentItems?api-version=2019-12-01`, managementApiAccessToken);
18-
const contentItems = data.value;
17+
const contentItems = [];
18+
let nextPageUrl = `https://${managementApiEndpoint}/subscriptions/00000/resourceGroups/00000/providers/Microsoft.ApiManagement/service/00000/contentTypes/${contentType}/contentItems?api-version=2019-12-01`;
19+
20+
do {
21+
const data = await request("GET", nextPageUrl, managementApiAccessToken);
22+
contentItems.push(...data.value);
23+
24+
if (data.value.length > 0 && data.nextLink) {
25+
nextPageUrl = data.nextLink;
26+
}
27+
else {
28+
nextPageUrl = null;
29+
}
30+
}
31+
while (nextPageUrl)
1932

2033
return contentItems;
2134
}

0 commit comments

Comments
 (0)