import axios from 'axios';

const service = axios.create({
  baseURL: '/',
});

service.interceptors.request.use((config) => {
  config.data && Object.assign(config.data, {
    _csrf: window.config ? window.config.csrf : '',
  });
  config.params && Object.assign(config.params, {
    _csrf: window.config ? window.config.csrf : '',
  });
  return config;
}, (error) => {
  return Promise.reject(error);
});

service.interceptors.response.use((response) => {
  return response;
}, (error) => {
  return Promise.reject(error);
});

export default service;
