1234567891011121314151617181920212223242526272829303132333435363738 |
- "use strict";
- import axios from "axios";
- let config = {
- baseURL: import.meta.env.VITE_APP_CYGX_BASEAPIURL,
- timeout: 60 * 1000, // Timeout
- };
- const _axios = axios.create(config);
- _axios.interceptors.request.use(
- function (config) {
- let auth = localStorage.getItem("Authorization") || "";
- if (auth) {
- config.headers.Authorization = auth;
- }
- return config;
- },
- function (error) {
- return Promise.reject(error);
- }
- );
- _axios.interceptors.response.use(
- function (response) {
- return response.data;
- },
- function (error) {
- return Promise.reject(error);
- }
- );
- export const get = (url, params) => {
- return _axios.get(url, { params });
- };
- export const post = (url, params) => {
- return _axios.post(url, params);
- };
|