32 lines
968 B
TypeScript
32 lines
968 B
TypeScript
import axios from "axios";
|
|
import * as bootstrap from "bootstrap";
|
|
|
|
/**
|
|
* We'll load the axios HTTP library which allows us to easily issue requests
|
|
* to our Laravel back-end. This library automatically handles sending the
|
|
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
|
*/
|
|
axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
|
|
|
|
window.axios = axios;
|
|
window.bootstrap = bootstrap;
|
|
|
|
// enable bs tooltips
|
|
const tooltipTriggerList = [].slice.call(
|
|
document.querySelectorAll("[data-bs-toggle=\"tooltip\"]")
|
|
);
|
|
tooltipTriggerList.map(function (tooltipTriggerEl) {
|
|
return new bootstrap.Tooltip(tooltipTriggerEl);
|
|
});
|
|
|
|
const token = document.head.querySelector("meta[name=\"csrf-token\"]");
|
|
|
|
if (token) {
|
|
window.axios.defaults.headers.common["X-CSRF-TOKEN"] = String(
|
|
token.textContent
|
|
);
|
|
} else {
|
|
console.error(
|
|
"CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token"
|
|
);
|
|
}
|