Parse body before calling back
This commit is contained in:
parent
cf1cf48873
commit
1e2dd873ee
1 changed files with 11 additions and 3 deletions
14
lib/bing.js
14
lib/bing.js
|
@ -1,7 +1,7 @@
|
|||
|
||||
/**************************************************************
|
||||
/*********************************************************
|
||||
* Simple Node.js module for using the Bing Search API *
|
||||
**************************************************************/
|
||||
*********************************************************/
|
||||
|
||||
// Require dependencies
|
||||
var request = require('request'),
|
||||
|
@ -65,7 +65,15 @@ Bing.prototype.search = function(query, callback, options) {
|
|||
},
|
||||
timeout: opts.reqTimeout
|
||||
|
||||
}, callback);
|
||||
}, function(err, res, body){
|
||||
|
||||
// Parse body, if body
|
||||
body = typeof body === 'string'
|
||||
? JSON.parse(body)
|
||||
: body;
|
||||
|
||||
callback(err, res, body);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Bing;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue