import axios from 'axios';
import JSONbig from 'json-bigint';

const service = axios.create({
   // crossDomain: true,
   // baseURL: process.env.VUE_APP_BASE_URL,
    timeout: 5000,
    transformResponse: [function (data) {
        return JSONbig.parse(data);
    }],
});

service.interceptors.request.use(
    config => {
        return config;
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject();
        }
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

export default service;
