All request methods in laravel returned (error 419 unknown status) except get request. How can I set token in header?
I tried to do this the following ways.
1)
window.onload = function() {
const ui = SwaggerUIBundle({
...
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
}
2)
window.onload = function() {
const ui = SwaggerUIBundle({
authorizations: {
csrf: function () {
var cookiearray = document.cookie.split(';');
for (var i = 0; i < cookiearray.length; ++i) {
if (cookiearray[i].trim().match('^XSRF-TOKEN=')) {
this.headers['RequestVerificationToken'] =
cookiearray[i].replace(`XSRF-TOKEN=`, '').trim();
}
}
return true;
},
}
}
}
but nothing has changed
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire