fediverse-export-analyzer/public/js/modules/fetchRequest.min.js

3 wiersze
815 B
JavaScript

import sleep from"/js/modules/sleep.min.js";const fetchRequest=async(a,s,c)=>{try{var i,r,o=await fetch(a,c);let e=await o.json(),t;switch(s){case"mastodon":case"hometown":case"friendica":case"pleroma":case"akkoma":(t=/<([^>]+)>; rel="next"/g.test(o.headers.get("link"))?/<([^>]+)>; rel="next"/g.exec(o.headers.get("link"))[1]:t)&&(await sleep(500),e=e.concat(await fetchRequest(t,s,c)));break;case"misskey":case"calckey":case"firefish":case"foundkey":case"magnetar":e.length===window.globalConfig.misskeyFetchLimit&&(e&&e.length&&(i=e.slice(-1)[0],(r=JSON.parse(c.body)).untilId=i.id,c.body=JSON.stringify(r)),await sleep(500),e=e.concat(await fetchRequest(a,s,c)))}return e}catch(e){return console.log("fetchRequest error",{error:e}),[]}};export default fetchRequest;
//# sourceMappingURL=fetchRequest.min.js.map