feat: total replies

This commit is contained in:
Nevo David 2025-06-13 14:17:03 +07:00
parent 3a31da4b41
commit 375002ca73
1 changed files with 6 additions and 2 deletions

View File

@ -27,11 +27,15 @@ export abstract class SocialAbstract {
totalRetries = 0
): Promise<Response> {
const request = await fetch(url, options);
``
if (request.status === 200 || request.status === 201) {
return request;
}
if (totalRetries > 2) {
throw new BadBody(identifier, '{}', options.body || '{}');
}
let json = '{}';
try {
json = await request.text();
@ -42,7 +46,7 @@ export abstract class SocialAbstract {
if (json.includes('rate_limit_exceeded') || json.includes('Rate limit')) {
await timer(2000);
return this.fetch(url, options, identifier);
return this.fetch(url, options, identifier, totalRetries + 1);
}
if (