You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
spa_instat_tv/src/helpers/callApi/logoutIfUnauthorized.tsx

20 lines
579 B

// import * as Sentry from '@sentry/react'
export const logoutIfUnauthorized = async (response: Response) => {
/* отключили из-за доступа без авторизации */
// if (response.status === 400) {
// Sentry.captureException(body)
// }
if (response.status === 401 || response.status === 403) {
window.dispatchEvent(new Event('FORBIDDEN_REQUEST'))
}
const error = new Error(response.statusText)
// eslint-disable-next-line no-console
console.error(error)
const body = await response.json()
return Promise.reject(body)
}