diff --git a/lib/user-methods.js b/lib/user-methods.js index 2414c101..216476ee 100644 --- a/lib/user-methods.js +++ b/lib/user-methods.js @@ -75,8 +75,6 @@ function refreshAccessToken(user, localRealmPath, realmUrl) { headers: postHeaders }; performFetch(url, options) - // in case something lower in the HTTP stack breaks, try again in 10 seconds - .catch(() => setTimeout(() => refreshAccessToken(user, localRealmPath, realmUrl), 10 * 1000)) .then((response) => response.json().then((json) => { return { response, json }; })) .then((responseAndJson) => { const response = responseAndJson.response; @@ -112,7 +110,11 @@ function refreshAccessToken(user, localRealmPath, realmUrl) { } } }) - .catch((e) => print_error(e)); + .catch((e) => { + print_error(e); + // in case something lower in the HTTP stack breaks, try again in 10 seconds + setTimeout(() => refreshAccessToken(user, localRealmPath, realmUrl), 10 * 1000); + }) } /** @@ -291,7 +293,6 @@ const instanceMethods = { throw new AuthError(body); }); } else { - return response.json(); } });