Skip to content

Commit

Permalink
fixes bugs with body request
Browse files Browse the repository at this point in the history
  • Loading branch information
h2rd committed Aug 27, 2015
1 parent d75455f commit 8001a49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
26 changes: 8 additions & 18 deletions lib/route4me.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ function Route4me(api_key) {

Route4me.prototype.setBaseUrl = function(base_url) {
this.url_base = base_url;
}
};

Route4me.prototype._useResources = function() {
for (var name in resources) {
this[name] = resources[name](this);
}
}
};

Route4me.prototype.getApiKey = function () {
return this.api_key;
};

Route4me.prototype._generateUrl = function(url) {
return this.url_base + url;
}
};

Route4me.prototype._makeRequest = function(options, callback) {
var qs = _.extend({
api_key: this.getApiKey()
}, options['qs'] || {});
delete options['qs'];
}, options.qs || {});
delete options.qs;

var body = JSON.stringify(options['body']);
delete options['body'];
var body = options.body;
delete options.body;

options = _.extend({
json: true
Expand All @@ -53,17 +53,7 @@ Route4me.prototype._makeRequest = function(options, callback) {
}, options);

request(options, function(err, res, body) {
if (err) {
console.log(err);
return callback(err);
}

if (404 === res.statusCode) {
console.log(body);
callback('Page not found');
} else {
callback(null, body);
}
callback(err, body);
});
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "route4me-node",
"version": "0.1.0",
"version": "0.1.1",
"description": "Access Route4Me's logistics-as-a-service API using our Node.js SDK",
"main": "lib/route4me.js",
"scripts": {
Expand Down
2 changes: 0 additions & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
var api_key = '11111111111111111111111111111111'
, route4me = require('../lib/route4me')(api_key);

route4me.setBaseUrl('http://staging.route4me.com:8080');

function getAddresses () {
return [
{
Expand Down

0 comments on commit 8001a49

Please sign in to comment.