chore: Add fetch-retry, remove isomorphic-fetch (#2297)

* chore: Add fetch-retry, remove isomorphic-fetch

closes #2270

* test: Mock fetch
This commit is contained in:
Tom Moor
2021-07-09 04:07:18 -07:00
committed by GitHub
parent b5e4e4fe82
commit 0e7d352781
5 changed files with 36 additions and 38 deletions

View File

@ -1,4 +1,5 @@
// @flow
import retry from "fetch-retry";
import invariant from "invariant";
import { map, trim } from "lodash";
import { getCookie } from "tiny-cookie";
@ -24,6 +25,8 @@ const CF_AUTHORIZATION = getCookie("CF_Authorization");
// if the cookie is set, we must pass it with all ApiClient requests
const CREDENTIALS = CF_AUTHORIZATION ? "same-origin" : "omit";
const fetchWithRetry = retry(fetch);
class ApiClient {
baseUrl: string;
userAgent: string;
@ -92,7 +95,7 @@ class ApiClient {
let response;
try {
response = await fetch(urlToFetch, {
response = await fetchWithRetry(urlToFetch, {
method,
body,
headers,