我在laravel 5.2上工作,我添加了vinkla/laravel-pusher來在我的網站上做實時聊天應用程序,但我遇到了這個問題: 「JSON從webapp返回的是無效的,但狀態碼是200。「 這是我的控制器:Laravel推送錯誤:從webapp返回的JSON無效,但狀態代碼是200
public function authMessageChat(Request $req)
{
$channelName = e($req->input('channel_name'));
$socketId = e($req->input('socket_id'));
$auth = $this->pusher->presence_auth($channelName, $socketId, auth()->user()->id);
return response($auth);
}
這是我的腳本:
var pusher = new Pusher('{{env("PUSHER_KEY")}}', {
authEndpoint: '../auth',
auth: {
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
params: {
id: currentUser.id
}
}
});
var channel = pusher.subscribe('{{$chatChannel}}');
channel.bind('pusher:subscription_error', function(PusherError){
console.log('PusherError' + PusherError);
});
channel.bind('new-message', function(data) {
console.log(data.sender);
)};
推錯誤: