promo! react
This commit is contained in:
+5
-4
@@ -28,18 +28,19 @@ export async function loadInitialData(): Promise<InitialData> {
|
||||
return retryResponse.json();
|
||||
}
|
||||
|
||||
// Handle 403 or need_refresh cases
|
||||
if (response.status === 403 || data.error_message === 'need_refresh') {
|
||||
await refreshToken();
|
||||
|
||||
const retryResponse = await fetch(apiUrl('/api/promo/get_initial_data'), {
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
return retryResponse.json();
|
||||
}
|
||||
|
||||
// Success case
|
||||
return data;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error('Error in loadInitialData:', error);
|
||||
return fallbackInitialData;
|
||||
}
|
||||
}
|
||||
@@ -116,4 +117,4 @@ const fallbackInitialData: InitialData = {
|
||||
days: 7,
|
||||
excess: 0,
|
||||
precision: 0,
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user