Just starting out with Vue.js and I recently finished developing a Vue.js app using the terminal. I then deployed it on a Java web application and noticed that everything works fine when running it as is.
However, I now need to pass a csrftoken to my Vue.js app. Initially, I hardcoded the token by setting
. Now, I realize that this approach isn't ideal as the token needs to be dynamic and fetched from the Java response session.Vue.prototype.$csrfToken = '*************************';
I attempted to define a global variable in the index page like -
var token = '<%= request.getSession().getAttribute("token") %>';
and then assign this variable in the Vue.js file using: Vue.prototype.$csrfToken = token;
.
Unfortunately, this method doesn't seem to work. Any ideas on how to tackle this issue effectively?