Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import axios, { AxiosTransformer } from "axios"; import { BASE_URL } from "./utils"; import { addAuthToken, redirectIfNotLoggedIn } from "./apps/authentication/utils"; // failed to respect module here because of a circular import issue axios.defaults.headers.common["Content-Type"] = "application/json"; const defaultRequestTransformers = (): AxiosTransformer[] => { const { transformRequest } = axios.defaults; Iif (!transformRequest) { return []; } else Eif (transformRequest instanceof Array) { return transformRequest; } else { return [transformRequest]; } }; const defaultResponseTransformers = (): AxiosTransformer[] => { const { transformResponse } = axios.defaults; Iif (!transformResponse) { return []; } else Eif (transformResponse instanceof Array) { return transformResponse; } else { return [transformResponse]; } }; const authenticatedInstance = axios.create({ baseURL: BASE_URL, transformRequest: [...defaultRequestTransformers(), addAuthToken], transformResponse: [...defaultResponseTransformers(), redirectIfNotLoggedIn] }); const unAuthenticatedInstance = axios.create({ baseURL: BASE_URL }); export { authenticatedInstance, unAuthenticatedInstance }; |