From e029861b5ab69f6820a6fc888d040e833227644b Mon Sep 17 00:00:00 2001 From: "wkylin.w@gmail.com" Date: Fri, 27 Dec 2024 12:03:35 +0800 Subject: [PATCH] feat: promise catch --- src/components/stateless/SkeletonFix/index.module.less | 7 +------ src/service/fetch.js | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/stateless/SkeletonFix/index.module.less b/src/components/stateless/SkeletonFix/index.module.less index 83a1e991..656c3baf 100644 --- a/src/components/stateless/SkeletonFix/index.module.less +++ b/src/components/stateless/SkeletonFix/index.module.less @@ -40,12 +40,7 @@ .shimmer::before { content: ''; position: absolute; - background: linear-gradient( - 90deg, - rgb(255 255 255 / 0%) 0%, - rgb(255 255 255 / 40%) 50%, - rgb(255 255 255 / 0%) 100% - ); + background: linear-gradient(90deg, rgb(255 255 255 / 0%) 0%, rgb(255 255 255 / 40%) 50%, rgb(255 255 255 / 0%) 100%); height: 100%; width: 100%; z-index: 1; diff --git a/src/service/fetch.js b/src/service/fetch.js index 8f60ee51..57ee13f8 100644 --- a/src/service/fetch.js +++ b/src/service/fetch.js @@ -102,7 +102,6 @@ const handleFetchData = (url, options) => { // console.error('err.message', err.message) // }) const contentType = response.headers.get('Content-Type') - console.log('response', response) if (response.status >= 200 && response.status < 300) { if (contentType.includes('application/json')) { response @@ -150,6 +149,8 @@ const handleFetchData = (url, options) => { }) .catch((error) => { handleFailedResult(error, error, isShowError) + // return error 会正常处理 + // return Promise.reject(error.response); 会进入catch }) .finally(() => clearTimeout(timer)) })