【问题标题】:Laravel Echo Cannot set property 'X-Socket-ID' of undefinedLaravel Echo 无法设置未定义的属性“X-Socket-ID”
【发布时间】:2017-01-13 23:42:13
【问题描述】:

我最近从 5.2 升级到 5.3。

上周我安装了 Laravel Echo,并将它与 Pusher、Vue 和 Vue-resource 一起使用。

每次我发布到我的数据库时都会收到此错误

Cannot set property 'X-Socket-ID' of undefined

文档说如果你使用 Vue 并且 Vue-resource X-Socket-ID 会自动附加到标头,但在这种情况下显然没有

有人知道如何解决这个问题吗?

错误来自此代码

Vue.http.interceptors.push(function (request, next) {
            if (_this.socketId()) {
                request.headers['X-Socket-ID'] = _this.socketId();
            }
            next();
        });

main.js

var Vue = require('vue');
window.moment = require('moment');
require("moment/locale/ja.js");
window.Vue = Vue;
Vue.use(require('vue-resource'));
window.Pusher = require('pusher-js');

import Echo from "laravel-echo"
window.Echo = new Echo({
 broadcaster: 'pusher',
 key: 'my key'
});

感谢您的帮助

【问题讨论】:

  • 你已经Vue.use(VueResource)了吗?
  • 是的,先生更新了原帖

标签: php laravel sockets pusher


【解决方案1】:

安装Vue-resource@^0.9.3后解决

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-07
    • 2020-09-19
    • 2021-11-27
    • 2016-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多