import axios from 'axios'
let axiosInstance = axios.create({
    // baseURL: 'http://ec2-35-179-84-240.eu-west-2.compute.amazonaws.com/',

    // baseURL:
    //     process?.env?.NODE_ENV !== 'development'
    //         ? 'https://istarhearing.com/'
    //         : 'http://localhost:8080/',
    // baseURL: 'http://localhost:4200/',
    // baseURL: 'https://allthingslocalapp.herokuapp.com/',
    // baseURL: 'http://192.168.10.13:4000/',
    // withCredentials: true,
    headers: {
        'Access-Control-Allow-Origin': '*',
        'Content-Type': 'application/json',
    },
})
axiosInstance.defaults.headers.common['x-auth-token'] = localStorage.getItem(
    'accessToken'
)
    ? localStorage.getItem('accessToken').toString()
    : ''

axiosInstance.defaults.headers.common['tenant'] = localStorage.getItem('tenant')
    ? localStorage.getItem('tenant').toString()
    : ''

// axiosInstance.defaults.headers.post["Content-Type"] = "application/json";
// axiosInstance.interceptors.response.use(
//   response => successHandler(response),
//   error => errorHandler(error)
// );
const errorHandler = (error) => {
    return Promise.reject({ ...error })
}

const successHandler = (response) => {
    return response
}
export default axiosInstance
