From 5c8287253f67df57db83f7f025567e3c6c568451 Mon Sep 17 00:00:00 2001 From: Dan Zajdband Date: Fri, 11 Jan 2013 16:32:06 -0300 Subject: [PATCH] working on windows environments --- lib/moviedb.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/moviedb.js b/lib/moviedb.js index 096d4a7..3b29c60 100644 --- a/lib/moviedb.js +++ b/lib/moviedb.js @@ -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);