Support retries fetching server config

This commit is contained in:
Gabe Kangas
2022-05-27 15:08:59 -07:00
parent 24738d7410
commit 7ac66faf48
5 changed files with 162 additions and 2 deletions

View File

@@ -1,9 +1,15 @@
import { ClientConfig } from '../interfaces/client-config.model';
const originalFetch = require('isomorphic-fetch');
const fetch = require('fetch-retry')(originalFetch);
const ENDPOINT = `http://localhost:8080/api/config`;
class ClientConfigService {
public static async getConfig(): Promise<ClientConfig> {
const response = await fetch(ENDPOINT);
const response = await fetch(ENDPOINT, {
retries: 20,
retryDelay: (attempt, error, response) => 3 ** attempt * 1000,
});
const status = await response.json();
return status;
}