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:
@ -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,
|
||||
|
Reference in New Issue
Block a user