fix(subsriptions stripe): fix stripe subscriptions

pull/52/head
Andrei Dekterev 3 years ago committed by Gitea
parent 9a6d3cae1b
commit 34dfd327bb
  1. 5
      src/helpers/callApi/index.tsx
  2. 11
      src/helpers/callApi/logoutIfUnauthorized.tsx

@ -2,6 +2,7 @@ import type { CallApiArgs } from './types'
import { parseJSON } from './parseJSON'
import { checkStatus } from './checkStatus'
import { getRequestConfig } from './getRequestConfig'
import { logoutIfUnauthorized } from './logoutIfUnauthorized'
export const callApiBase = ({
abortSignal,
@ -38,7 +39,7 @@ const callApiWithTimeout = (args: CallApiArgs) => {
})
.then(checkStatus)
.then(parseJSON)
// .catch(logoutIfUnauthorized)
.catch(logoutIfUnauthorized)
.finally(() => clearTimeout(timeoutId))
}
@ -48,5 +49,5 @@ export const callApi = (args: CallApiArgs) => {
return callApiBase(args)
.then(checkStatus)
.then(parseJSON)
// .catch(logoutIfUnauthorized)
.catch(logoutIfUnauthorized)
}

@ -1,10 +1,9 @@
import { removeToken } from 'helpers'
export const logoutIfUnauthorized = async (response: Response) => {
if (response.status === 401 || response.status === 403) {
removeToken()
window.dispatchEvent(new Event('FORBIDDEN_REQUEST'))
}
/* отключили из-за доступа без авторизации */
// if (response.status === 401 || response.status === 403) {
// removeToken()
// window.dispatchEvent(new Event('FORBIDDEN_REQUEST'))
// }
const error = new Error(response.statusText)
// eslint-disable-next-line no-console

Loading…
Cancel
Save