centrifugal / jscent

Node.js client to interact with Centrifugo v1 HTTP API
MIT License
11 stars 5 forks source link

ReferenceError: url is not defined #1

Closed alfredwesterveld closed 8 years ago

alfredwesterveld commented 8 years ago

Running linux ubuntu node:

alfred@alfred-SATELLITE-C55-A-1ND:~/centritest/server$ node -v
v4.1.1

I created test.js:

Client = require("jscent")

var options = {
    url: "http://localhost:8000", 
    secret: "e2199fe7-ebad-4124-a8fa-d6c95653bcd8"
}

var c = new Client(options)

c.publish("alfred", "test", function (err, resp) {
    console.log(err, resp)
})

when I ran node test.js I got an error that url is not defined.

/home/alfred/centritest/server/node_modules/jscent/lib/requests.js:16
    handleResponse(err, url, res, callback);
                        ^
ReferenceError: url is not defined

in jscent/lib at line 16 I modified url to config.url

request["post"](params, function(err, res) {
    handleResponse(err, config.url, res, callback);
  });

Now I get:

alfred@alfred-SATELLITE-C55-A-1ND:~/centritest/server$ node test.js 
null { body: null, error: null, method: 'publish' }
FZambia commented 8 years ago

Hello! Thank you very much for opening this, seems you are first using Centrifugo with NodeJS:)

Pushed a fix, made new release 0.1.1 - should work now.

alfredwesterveld commented 8 years ago

Hi Fzambia. I updated dependency and know I can run the code. Thanks for fixing so quick.