Comparing version 2.8.6 to 2.9.0
@@ -1,1 +0,1 @@ | ||
{"name":"ft-poller","version":"2.8.6","repository":{"type":"git","url":"https://github.com/Financial-Times/ft-poller"},"license":"MIT","description":"An http client to periodically fetch and cache data from web services","main":"./src/server.js","directories":{"lib":"./lib"},"dependencies":{"isomorphic-fetch":"^2.0.0","n-eager-fetch":"^2.0.0"},"devDependencies":{"chai":"^3.3.0","eslint":"^2.9.0","lintspaces-cli":"^0.1.1","mocha":"^2.3.3","nock":"^2.13.0","npm-prepublish":"^1.2.2","sinon":"^1.10.3","timer-shim":"^0.3.0"}} | ||
{"name":"ft-poller","version":"2.9.0","repository":{"type":"git","url":"https://github.com/Financial-Times/ft-poller"},"license":"MIT","description":"An http client to periodically fetch and cache data from web services","main":"./src/server.js","directories":{"lib":"./lib"},"dependencies":{"isomorphic-fetch":"^2.0.0","n-eager-fetch":"^2.0.0"},"devDependencies":{"chai":"^3.3.0","eslint":"^2.9.0","lintspaces-cli":"^0.1.1","mocha":"^2.3.3","nock":"^2.13.0","npm-prepublish":"^1.2.2","sinon":"^1.10.3","timer-shim":"^0.3.0"}} |
'use strict'; | ||
const errors = require('./errors'); | ||
@@ -84,6 +85,6 @@ require ('isomorphic-fetch'); | ||
const latency = new Date () - time; | ||
if (response.status === 200) { | ||
if (response.ok) { | ||
this.emit ('ok', response, latency); | ||
} else { | ||
throw new Error (`Fetching ${response.url} failed with a ${response.status}, ${response.statusText}`); | ||
throw new errors.HttpError({url:this.url, method:this.options.method || 'GET', response}); | ||
} | ||
@@ -90,0 +91,0 @@ if ((response.headers.get ('content-type') || '').indexOf ('json') > -1) { |
@@ -8,2 +8,3 @@ /* global it, describe, xit */ | ||
const expect = chai.expect; | ||
const HttpError = require('../src/errors').HttpError; | ||
@@ -165,2 +166,3 @@ describe ('Poller', function () { | ||
expect (eventEmitterStub.getCall (0).args[0]).to.equal ('error'); | ||
expect(eventEmitterStub.getCall (0).args[1]).to.be.an.instanceOf(HttpError); | ||
done (); | ||
@@ -167,0 +169,0 @@ }, 10); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24425
12
411