Newer
Older
taehui / qwilight-fe / src / utilities / wwwAPI.ts
@Taehui Taehui on 17 Mar 518 bytes 2024-03-17 오후 2:12
import axios, { AxiosError } from "axios";
import { toast } from "react-toastify";

export const wwwAPIPath = "/qwilight/www";

export const wwwAPI = axios.create({
  baseURL: wwwAPIPath,
});

wwwAPI.interceptors.response.use(
  (value) => value,
  (e: AxiosError) => {
    switch (e.response?.status) {
      case 401:
        toast.error("Unauthorized");
        window.sessionStorage.removeItem("totem");
        break;
      case 502:
        toast.error("Bad Gateway");
        break;
    }

    throw e;
  },
);