admin管理员组

文章数量:1395730

 pusher.trigger('test_channel', 'my_evenHt', {"message": "hello world"});

   var channel = pusher.subscribe('test_channel');
  channel.bind('my-event', function(data) {
   alert('An event was triggered with message: ' + data.message);
  });

  pusher.trigger('test_channel', 'my_event', {"message": "hello world"});

I've initialized pusher at the top of the file. Here is the internals of a method thats throwing the error. The pusher.trigger() function works correctly, but the next line throws an error on pusher.subcribe();

TypeError: pusher.subscribe is not a function

Why would this be happening?

 pusher.trigger('test_channel', 'my_evenHt', {"message": "hello world"});

   var channel = pusher.subscribe('test_channel');
  channel.bind('my-event', function(data) {
   alert('An event was triggered with message: ' + data.message);
  });

  pusher.trigger('test_channel', 'my_event', {"message": "hello world"});

I've initialized pusher at the top of the file. Here is the internals of a method thats throwing the error. The pusher.trigger() function works correctly, but the next line throws an error on pusher.subcribe();

TypeError: pusher.subscribe is not a function

Why would this be happening?

Share Improve this question asked Jun 13, 2016 at 7:15 OrbitOrbit 2,39510 gold badges55 silver badges110 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

I assume you're using pusher-http-node? Pusher-http-node does not have the subscribe function, as it is a server http library.

If you wish to use our JS websocket library on the server, you can npm install pusher-js, and import pusher-js/node.

Thanks

You have to pass the API key for channel subscribe the channel.

https://github./dirkbonhomme/pusher-client-node#global-events

本文标签: javascriptpushersubcribe() is not a functionStack Overflow