I\'m using VueJS in my front-end, so I have this API call somewhere in the front-end code:
let products = axios.get(\'api/products\');
Make sure you're sending the CSRF token, somewhere in your bootstrap.js
file, you should have something like this. Also make sure you have the csrf
token somewhere in the meta tag
let token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN': Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest'
};
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}