react-native-update 10.30.0 → 10.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils.ts +17 -6
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -108,10 +108,21 @@ export const assertWeb = () => {
|
|
|
108
108
|
export const enhancedFetch = async (
|
|
109
109
|
url: string,
|
|
110
110
|
params: Parameters<typeof fetch>[1],
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
isRetry = false,
|
|
112
|
+
): Promise<Response> => {
|
|
113
|
+
return fetch(url, params)
|
|
114
|
+
.then(r => {
|
|
115
|
+
if (r.ok) {
|
|
116
|
+
return r;
|
|
117
|
+
}
|
|
118
|
+
throw new Error(`${r.status} ${r.statusText}`);
|
|
119
|
+
})
|
|
120
|
+
.catch(e => {
|
|
121
|
+
log('fetch error', url, e);
|
|
122
|
+
if (isRetry) {
|
|
123
|
+
throw e;
|
|
124
|
+
}
|
|
125
|
+
log('trying fallback to http');
|
|
126
|
+
return enhancedFetch(url.replace('https', 'http'), params, true);
|
|
127
|
+
});
|
|
117
128
|
};
|