danwrong/restler — Issue #62: error calling get on service
Author: edrex
Created: 2012-01-11 20:48:29+00:00
State: open

Calling get on a service results in a fatal error. I'm not sure if I misunderstand the purpose of the service constructor, or if this is a bug. Should I be able to call get/post/etc directly?

Failing code slightly adapted from service example:

```javascript

var sys = require('util'),
rest = require('restler');
// create a service constructor for very easy API wrappers a la HTTParty...
Twitter = rest.service(function(u, p) {
this.defaults.username = u;
this.defaults.password = p;
}, {
baseURL: 'http://twitter.com'
}, {
update: function(message) {
return this.post('/statuses/update.json', { data: { status: message } });
}
});

var client = new Twitter('danwrong', 'password');
client.get('/').on('complete', function(data) {
sys.p(data);
});
```

```node twittest.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object.keys called on non-object
at Function.keys (native)
at mixin (./node_modules/restler/lib/restler.js:10:10)
at Service._withDefaults (./node_modules/restler/lib/restler.js:320:12)
at Service.get ./node_modules/restler/lib/restler.js:303:38)
at Object. (./twittest.js:16:8)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
```

node 0.6.2
restler 0.2.4