How to pass laravel CSRF token value to vue

后端 未结 6 667
滥情空心
滥情空心 2020-12-02 22:57

I have this form where the user should only type text inside a text area:

            
{{-- Name of the me
6条回答
  •  無奈伤痛
    2020-12-02 23:41

    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.

提交回复
热议问题