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",
|
"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": {
|
||||||
|
@@ -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);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user