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

bump version to 10.30.2 and improve error handling in enhancedFetch function

This commit is contained in:
sunnylqm
2025-08-30 11:53:52 +08:00
parent 02517a9eb0
commit 4a1d4d5a50
2 changed files with 7 additions and 3 deletions

View File

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

View File

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