Can't subscribe to Pusher channel using nodejs

I'm trying to use the Pusher nodejs module to subscribe to Bitstamp's live orderbook feed.

var Pusher = require('pusher');
var pusher = new Pusher('de504dc5763aeef9ff52');
var order_book_channel = pusher.subscribe('order_book')

Nodejs replies with:

TypeError: Object #<Pusher> has no method 'subscribe'

Not too sure where the problem lies, any help would be appreciated.

Kind regards, Christian

Upvotes: 1

Views: 1788

Answers (1)

Instead of pusher library, require the pusher-client library.

From there on proceed as normal..

var Pusher = require('pusher-client');
var pusher = new Pusher('de504dc5763aeef9ff52');
var order_book_channel = pusher.subscribe('order_book');
order_book_channel.bind('data', function(data) {
    console.log(data);
})

Upvotes: 8

Related Questions