Skip to content

Commit 02517a9

Browse files
committed
bump version to 10.30.1 and enhance error handling in enhancedFetch function
1 parent f7309f6 commit 02517a9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.30.0",
3+
"version": "10.30.1",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/utils.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,16 @@ export const enhancedFetch = async (
109109
url: string,
110110
params: Parameters<typeof fetch>[1],
111111
) => {
112-
return fetch(url, params).catch(e => {
113-
log('fetch error', url, e);
114-
log('trying fallback to http');
115-
return fetch(url.replace('https', 'http'), params);
116-
});
112+
return fetch(url, params)
113+
.then(r => {
114+
if (r.ok) {
115+
return r;
116+
}
117+
throw new Error(`${r.status} ${r.statusText}`);
118+
})
119+
.catch(e => {
120+
log('fetch error', url, e);
121+
log('trying fallback to http');
122+
return fetch(url.replace('https', 'http'), params);
123+
});
117124
};

0 commit comments

Comments
 (0)