import Vue from 'vue'
import VueAxios from 'vue-axios'
import axios from 'axios'

Vue.use(VueAxios, axios)

// // baseUrl is a global variable, we get it through Laravel
// console.log(process.env.NODE_ENV)
const baseUrl = process.env.NODE_ENV === 'production' ? window.Laravel.baseUrl : 'http://127.0.0.1:8000'

Vue.axios.defaults.baseURL = baseUrl + '/api'
// Don't throw errors on 422, 403 and 401 status code (used for validations)
Vue.axios.defaults.validateStatus = status => {
  return status === 422 || status === 400 || status === 401 || status === 403 || status === 404 || (status >= 200 && status < 300)
}
