| 58 | } |
| 59 | |
| 60 | export 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 | |
| 81 | export async function single( |
| 82 | el: { |