feat: total replies
This commit is contained in:
parent
3a31da4b41
commit
375002ca73
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Reference in New Issue