Skip to content

Commit

Permalink
fix: Ignore the error toast notification if the status is 401 and isP…
Browse files Browse the repository at this point in the history
…ublicAPI is true (langgenius#9062)
  • Loading branch information
douxc authored Oct 8, 2024
1 parent 7c0b159 commit 4abca86
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions web/service/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@ const baseFetch = <T>(
case 401: {
if (isPublicAPI) {
return bodyJson.then((data: ResponseError) => {
if (!silent)
Toast.notify({ type: 'error', message: data.message })

if (data.code === 'web_sso_auth_required')
requiredWebSSOLogin()

Expand Down Expand Up @@ -536,8 +533,6 @@ export const ssePost = (
.then((res) => {
if (!/^(2|3)\d{2}$/.test(String(res.status))) {
res.json().then((data: any) => {
Toast.notify({ type: 'error', message: data.message || 'Server Error' })

if (isPublicAPI) {
if (data.code === 'web_sso_auth_required')
requiredWebSSOLogin()
Expand All @@ -546,7 +541,10 @@ export const ssePost = (
removeAccessToken()
globalThis.location.reload()
}
if (res.status === 401)
return
}
Toast.notify({ type: 'error', message: data.message || 'Server Error' })
})
onError?.('Server Error')
return
Expand Down

0 comments on commit 4abca86

Please sign in to comment.