I have this form where the user should only type text inside a text area:
Simply, I would suggest to put this in your PHP file:
This way you're able to easily import your csrfToken from the JS part (Vue in this case).
Moreover, if you insert this code in your PHP layout file, you can use the token by any component of your app, since window
is a JS global variable.
Source: I got the trick from this post.