mirror of
https://github.com/KevinMidboe/moviedb.git
synced 2025-10-29 17:50:25 +00:00
Merge pull request #34 from angelxmoreno/superagent_update
Updating superagent and using new syntax
This commit is contained in:
@@ -36,12 +36,13 @@ MovieDB.prototype.requestToken = function(fn){
|
|||||||
.get(endpoints.base_url + endpoints.authentication.requestToken)
|
.get(endpoints.base_url + endpoints.authentication.requestToken)
|
||||||
.query({'api_key': self.api_key})
|
.query({'api_key': self.api_key})
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.end(function(res){
|
.end(function(err, res){
|
||||||
if(!res.ok) return fn(res.error);
|
if(err) {
|
||||||
self.token = res.body;
|
fn(err);
|
||||||
fn();
|
} else {
|
||||||
}).on('error', function(error){
|
self.token = res.body;
|
||||||
fn(error);
|
fn();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -90,10 +91,11 @@ var execMethod = function(type, params, endpoint, fn){
|
|||||||
else
|
else
|
||||||
req.send(params);
|
req.send(params);
|
||||||
|
|
||||||
req.end(function(res){
|
req.end(function(err, res){
|
||||||
if(res.ok) fn(null, res.body);
|
if(err){
|
||||||
else fn(res.error, null);
|
fn(err);
|
||||||
|
} else {
|
||||||
|
fn(null, res.body);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on('error', fn);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,12 +25,11 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Dan Zajdband <dan.zajdband@gmail.com>",
|
"author": "Dan Zajdband <dan.zajdband@gmail.com>",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chai": "^3.4.1",
|
"superagent": "^1.6.1"
|
||||||
"colors": "^1.1.2",
|
|
||||||
"superagent": "0.21.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.4.1",
|
"chai": "^3.4.1",
|
||||||
|
"colors": "^1.1.2",
|
||||||
"mocha": "^2.3.4"
|
"mocha": "^2.3.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user