mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-10-23 09:38:52 +08:00
bump version to 10.30.2 and improve error handling in enhancedFetch function
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.30.1",
|
||||
"version": "10.30.2",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
|
@@ -108,7 +108,8 @@ export const assertWeb = () => {
|
||||
export const enhancedFetch = async (
|
||||
url: string,
|
||||
params: Parameters<typeof fetch>[1],
|
||||
) => {
|
||||
isRetry = false,
|
||||
): Promise<Response> => {
|
||||
return fetch(url, params)
|
||||
.then(r => {
|
||||
if (r.ok) {
|
||||
@@ -118,7 +119,10 @@ export const enhancedFetch = async (
|
||||
})
|
||||
.catch(e => {
|
||||
log('fetch error', url, e);
|
||||
if (isRetry) {
|
||||
throw e;
|
||||
}
|
||||
log('trying fallback to http');
|
||||
return fetch(url.replace('https', 'http'), params);
|
||||
return enhancedFetch(url.replace('https', 'http'), params, true);
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user