Skip to content

Commit

Permalink
feat: 为 401 403 添加合适的 error message
Browse files Browse the repository at this point in the history
  • Loading branch information
pany-ang committed Feb 7, 2025
1 parent d82f3ec commit 95a8604
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/http/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ function createInstance() {
(error) => {
// status 是 HTTP 状态码
const status = get(error, "response.status")
const message = get(error, "response.data.message")
switch (status) {
case 400:
error.message = "请求错误"
break
case 401:
// Token 过期时
error.message = message || "未授权"
logout()
break
case 403:
error.message = "拒绝访问"
error.message = message || "拒绝访问"
break
case 404:
error.message = "请求地址出错"
Expand Down

0 comments on commit 95a8604

Please sign in to comment.