1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-22 15:36:10 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Compare commits

...

2 Commits

2 changed files with 18 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "10.30.0",
"version": "10.30.2",
"description": "react-native hot update",
"main": "src/index",
"scripts": {

View File

@@ -108,10 +108,21 @@ export const assertWeb = () => {
export const enhancedFetch = async (
url: string,
params: Parameters<typeof fetch>[1],
) => {
return fetch(url, params).catch(e => {
log('fetch error', url, e);
log('trying fallback to http');
return fetch(url.replace('https', 'http'), params);
});
isRetry = false,
): Promise<Response> => {
return fetch(url, params)
.then(r => {
if (r.ok) {
return r;
}
throw new Error(`${r.status} ${r.statusText}`);
})
.catch(e => {
log('fetch error', url, e);
if (isRetry) {
throw e;
}
log('trying fallback to http');
return enhancedFetch(url.replace('https', 'http'), params, true);
});
};