MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / getAllAlbums

Function getAllAlbums

scripts/test.js:487–506  ·  view source on GitHub ↗
(id, access_token)

Source from the content-addressed store, hash-verified

485 }
486
487 async function getAllAlbums(id, access_token) {
488 let result = [];
489 let after = "";
490 while (true) {
491 try {
492 const res = await fetch(
493 `https://graph.facebook.com/v20.0/${id}/albums?fields=type,name,count,link,created_time&limit=100&access_token=${access_token}&after=${after}`
494 );
495 const json = await res.json();
496 if (json.data) result = result.concat(json.data);
497
498 let nextAfter = json.paging?.cursors?.after;
499 if (!nextAfter || nextAfter === after) break;
500 after = nextAfter;
501 } catch (e) {
502 break;
503 }
504 }
505 return result;
506 }
507
508 async function fetchAlbumPhotosFromCursor({
509 cursor,

Callers 1

test.jsFile · 0.85

Calls 1

concatMethod · 0.80

Tested by

no test coverage detected