From 1e2dd873ee811f70f2ec923a2280209a6271c867 Mon Sep 17 00:00:00 2001 From: goferito Date: Fri, 19 Sep 2014 14:30:02 +0200 Subject: [PATCH] Parse body before calling back --- lib/bing.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/bing.js b/lib/bing.js index d4b4f0d..1ce78f8 100644 --- a/lib/bing.js +++ b/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;