From 76c73403c128ea31c84c021c3e3599c8ef35a8cc Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Mon, 24 Nov 2014 16:47:06 +0000 Subject: [PATCH] conditionally parsing as JSON (sometimes request does it for us) --- package.json | 2 +- src/poller.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7cdf11..0aaf1e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ft-poller", - "version": "1.0.0", + "version": "1.0.1", "repository": { "type": "git", "url": "https://github.com/Financial-Times/ft-poller" diff --git a/src/poller.js b/src/poller.js index 964097d..57d2695 100644 --- a/src/poller.js +++ b/src/poller.js @@ -70,7 +70,7 @@ Poller.prototype.fetch = function () { var latency = new Date() - time; if (response.statusCode === 200) { self.emit('ok', response, latency); - return JSON.parse(response.body); + return self.options.json ? response.body : JSON.parse(response.body); } else { throw response.body; }