import axios from 'axios';

axios.defaults.baseURL = 'http://180.108.205.89:8011/'

// 请求拦截
axios.interceptors.request.use(
    (config) => {
        console.log(`请求地址：${axios.duefaults.baseURL}${config.url} （axios拦截器）`);
        config.headers['Authorization'] = 'Bearer ' + sessionStorage.getItem('token')
        return config;
    },
    (error) => {
        return Promise.reject(error);
    }
);
// 响应拦截
axios.interceptors.response.use(
    function (response) {
        console.log('↓↓↓ axios响应的数据 ↓↓↓');
        console.log(JSON.parse(JSON.stringify(response.data)));
        console.log('↑↑↑ axios响应的数据 ↑↑↑');
        return response;
    },
    function (error) {
        return Promise.reject(error);
    }
);



// get
export function get() {
    return axios({
        method: 'get',
        url: '/get',
    })
}

// post
export function post(data) {
    return axios({
        method: 'POST',
        url: '/post',
        data: data
    })
}
