import Vue from 'vue'
import axios from 'axios'
import PrehliadacComponent from './App'
import { ToastPlugin } from 'bootstrap-vue'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.use(ToastPlugin)

new Vue({
  el: '#prehliadacUcebnehoMaterialuApp',
  components: {
    PrehliadacComponent
  },
  mounted: function () {
    window.axios = axios
    window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
    window.axios.defaults.baseURL = '/api/vzdelavanie/kniznica/'

    let token = document.head.querySelector('meta[name="csrf-token"]');

    if (token) {
      window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
    } else {
      console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
    }
  },
})
