Hi , i want to make AJAX request on admin controller from admin backend.
fileName.html.twig
<button v-on:click="makeAjaxRequest">Click</button>
index.js
makeAjaxRequest(){
let header = {
method:"POST",
headers:{"Content-Type":"application/json",Authorization:"Access token fetched from cookie"}
};
fetch("url",header).then((data)=>{
console.log(data);
}).catch((error)=>{
console.log(error);
});
}
I think access token is valid for 10 min . After that i have to refresh a page or regenerate access token . What will be the best way to make ajax request ?
i am trying to avoid access token handling .