Skip to content

Commit

Permalink
Fix when to raise an error
Browse files Browse the repository at this point in the history
  • Loading branch information
RulaKhaled committed Mar 18, 2024
1 parent cc47d69 commit b90839e
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/shared/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,16 @@ function graphql({
) {
window.location.href = '/login'
}

return Promise.reject({
status: data?.errors?.[0]?.extensions?.status,
data: data?.errors?.[0]?.message,
})
}

if (!res.ok) {
return Promise.reject({
status: res.status,
data: data,
})
if (res.ok) {
return data
}

return data
return Promise.reject({
status: res.status,
data: data,
})
})
}

Expand Down

0 comments on commit b90839e

Please sign in to comment.