working on windows environments

This commit is contained in:
Dan Zajdband
2013-01-11 16:32:06 -03:00
parent ce5b51f637
commit 5c8287253f

View File

@@ -33,7 +33,7 @@ MovieDB.prototype.requestToken = function(fn){
request
.get(endpoints.base_url + endpoints.authentication.requestToken)
.send({'api_key': self.api_key})
.query({'api_key': self.api_key})
.set('Accept', 'application/json')
.end(function(res){
if(res.ok) self.token = res.body;
@@ -77,11 +77,16 @@ var execMethod = function(type, params, endpoint, fn){
endpoint = endpoint.replace(':id', params.id);
type = type.toUpperCase();
request(type, endpoints.base_url + endpoint)
.query({api_key : this.api_key})
.send(params)
.set('Accept', 'application/json')
.end(function(res){
var req = request(type, endpoints.base_url + endpoint)
.query({api_key : this.api_key})
.set('Accept', 'application/json');
if(type === 'GET')
req.query(params);
else
req.send(params);
req.end(function(res){
if(res.ok) fn(null, res.body);
else if(res.body && res.body.status_message) fn(new Error(res.body.status_message), null);
else fn(new Error(res.text), null);