MCPcopy Create free account
hub / github.com/MALSync/MALSync / predictionXhrPOST

Function predictionXhrPOST

src/background/releaseProgressUtils.ts:60–79  ·  view source on GitHub ↗
(type: string, malDATA: listElement[] | null)

Source from the content-addressed store, hash-verified

58}
59
60export async function predictionXhrPOST(type: string, malDATA: listElement[] | null) {
61 if (malDATA === null) return [];
62 if (malDATA.length <= 0) return [];
63 const malDATAID = malDATA.map(el => el.apiCacheKey);
64 const returnArray: xhrResponseI[] = [];
65 for (let i = 0; i <= malDATAID.length; ) {
66 const tempArray = malDATAID.slice(i, i + 49);
67 const Request = {
68 url: `https://api.malsync.moe/nc/mal/${type}/POST/pr`,
69 data: JSON.stringify({ malids: tempArray }),
70 headers: { 'Content-Type': 'application/json' },
71 };
72 await utils.wait(5000);
73 const response = await api.request.xhr('POST', Request);
74 returnArray.push(JSON.parse(response.responseText));
75 i += 50;
76 }
77
78 return returnArray.reduce((acc: xhrResponseI[], val) => acc.concat(val), []);
79}
80
81export async function single(
82 el: {

Callers 1

multipleFunction · 0.90

Calls 1

xhrMethod · 0.80

Tested by

no test coverage detected