Skip to content

Commit

Permalink
feat: promise catch
Browse files Browse the repository at this point in the history
  • Loading branch information
wkylin committed Dec 27, 2024
1 parent 55900e3 commit e029861
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/components/stateless/SkeletonFix/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/service/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
})
Expand Down

0 comments on commit e029861

Please sign in to comment.