vue.js - Laravel is not defined when using vue-resource in Laravel 5.3
天蓬老师
天蓬老师 2017-05-16 16:49:23
0
1
523

Using vue-resource in VUE single file component

this.$http.get

Error after webpack
The code prompt is in bootstrap.js

Vue.http.interceptors.push((request, next) => {
    request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);

    next();
});

This sentence is wrong! The error message Laravel is not defined!

Delete this sentence and run it normally!

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
为情所困
Laravel.csrfToken

Token cannot be obtained in this way. . . You need {{}} to parse the template, otherwise laravel will directly output Laravel.csrfToken into the js code, so that js will mistakenly think that Laravel is an object.

Tips: Remember to add quotation marks.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template