File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ export const initDeezerApi = async (arl: string): Promise<string> => {
5454 return data . results . SESSION ;
5555} ;
5656
57+ let token_retry = 0 ;
58+
5759// Add a request interceptor
5860instance . interceptors . response . use ( async ( response : Record < string , any > ) => {
5961 if ( response . data . error && Object . keys ( response . data . error ) . length > 0 ) {
@@ -63,8 +65,10 @@ instance.interceptors.response.use(async (response: Record<string, any>) => {
6365 } else if ( response . data . error . code === 4 ) {
6466 await delay . range ( 1000 , 1500 ) ;
6567 return await instance ( response . config ) ;
66- } else if ( response . data . error . GATEWAY_ERROR ) {
67- getApiToken ( ) ;
68+ } else if ( response . data . error . GATEWAY_ERROR || ( response . data . error . VALID_TOKEN_REQUIRED && token_retry < 15 ) ) {
69+ await getApiToken ( ) ;
70+ // Prevent dead loop
71+ token_retry += 1 ;
6872 return await instance ( response . config ) ;
6973 }
7074 }
You can’t perform that action at this time.
0 commit comments