Skip to content

Commit 375002c

Browse files
committed
feat: total replies
1 parent 3a31da4 commit 375002c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libraries/nestjs-libraries/src/integrations/social.abstract.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ export abstract class SocialAbstract {
2727
totalRetries = 0
2828
): Promise<Response> {
2929
const request = await fetch(url, options);
30-
30+
``
3131
if (request.status === 200 || request.status === 201) {
3232
return request;
3333
}
3434

35+
if (totalRetries > 2) {
36+
throw new BadBody(identifier, '{}', options.body || '{}');
37+
}
38+
3539
let json = '{}';
3640
try {
3741
json = await request.text();
@@ -42,7 +46,7 @@ export abstract class SocialAbstract {
4246

4347
if (json.includes('rate_limit_exceeded') || json.includes('Rate limit')) {
4448
await timer(2000);
45-
return this.fetch(url, options, identifier);
49+
return this.fetch(url, options, identifier, totalRetries + 1);
4650
}
4751

4852
if (

0 commit comments

Comments
 (0)