File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
libraries/nestjs-libraries/src/integrations Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1+ import { timer } from '@gitroom/helpers/utils/timer' ;
2+
13export class RefreshToken {
24 constructor (
35 public identifier : string ,
@@ -18,7 +20,7 @@ export class NotEnoughScopes {
1820}
1921
2022export abstract class SocialAbstract {
21- async fetch ( url : string , options : RequestInit = { } , identifier = '' ) {
23+ async fetch ( url : string , options : RequestInit = { } , identifier = '' ) : Promise < Response > {
2224 const request = await fetch ( url , options ) ;
2325
2426 if ( request . status === 200 || request . status === 201 ) {
@@ -33,6 +35,11 @@ export abstract class SocialAbstract {
3335 json = '{}' ;
3436 }
3537
38+ if ( json . includes ( 'rate_limit_exceeded' ) || json . includes ( 'Rate limit' ) ) {
39+ await timer ( 2000 ) ;
40+ return this . fetch ( url , options , identifier ) ;
41+ }
42+
3643 if ( request . status === 401 || json . includes ( 'OAuthException' ) ) {
3744 throw new RefreshToken ( identifier , json , options . body ! ) ;
3845 }
You can’t perform that action at this time.
0 commit comments