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

bump version to 10.30.1 and enhance error handling in enhancedFetch function

This commit is contained in:
sunnylqm
2025-08-30 11:14:01 +08:00
parent f7309f699f
commit 02517a9eb0
2 changed files with 13 additions and 6 deletions

View File

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

View File

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