Skip to content

Commit

Permalink
Update to re add catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
RulaKhaled committed Mar 25, 2024
1 parent 9cfa8b7 commit e30d8f1
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/shared/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,31 @@ function graphql({
query,
variables,
}),
}).then(async (res) => {
const data = await res.json()

if (data?.errors) {
if (
data?.errors?.[0]?.extensions?.status === 403 &&
config.IS_SELF_HOSTED
) {
window.location.href = '/login'
})
.then(async (res) => {
const data = await res.json()

if (data?.errors) {
if (
data?.errors?.[0]?.extensions?.status === 403 &&
config.IS_SELF_HOSTED
) {
window.location.href = '/login'
}
}
}

if (res.ok) {
return data
}
if (res.ok) {
return data
}

return Promise.reject({
status: res.status,
data: data,
return Promise.reject({
status: res.status,
data: data,
})
})
.catch((error) => {
return Promise.reject(error)
})
})
}

function graphqlMutation({ mutationPath, ...graphqlParams }) {
Expand Down

0 comments on commit e30d8f1

Please sign in to comment.