Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Anchel123 committed Feb 4, 2025
1 parent 8249f78 commit af68537
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@ export async function securedFetch(

const response = await fetch(`${url}${url.includes("?") ? "&" : "?"}role=${role}`, init)
const { status } = response

if (status >= 300) {
response.json().then((err) => {
if (toast) {
toast({
title: "Error",
description: err.message,
variant: "destructive"
})
}
}).then(() => {
if (status === 401 || status >= 500) {
signOut({ callbackUrl: '/login' })
}
})
const err = await response.text()
if (toast) {
toast({
title: "Error",
description: err,
variant: "destructive"
})
}
if (status === 401 || status >= 500) {
signOut({ callbackUrl: '/login' })
}
}
return response
}
Expand Down

0 comments on commit af68537

Please sign in to comment.