search

Home  >  Q&A  >  body text

vue.js - Laravel is not defined when using vue-resource in Laravel 5.3

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!

天蓬老师天蓬老师2845 days ago550

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-16 16:51:23

    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.

    reply
    0
  • Cancelreply