Comparing version
12
index.js
@@ -103,5 +103,13 @@ "use strict"; | ||
} | ||
var error = errorOnRemoteError ? new VError("%s yielded %s (%s)", url, res.statusCode, util.inspect(content)) : null; | ||
errorAge = maxAgeFn(errorAge, cacheKey, res, content); | ||
return resolvedCallback(error, cacheValueFn(undefined, res.headers, res.statusCode), errorAge); | ||
if (errorOnRemoteError) { | ||
var error = new VError("%s yielded %s (%s)", url, res.statusCode, util.inspect(content)); | ||
error.statusCode = res.statusCode; | ||
return resolvedCallback(error, cacheValueFn(undefined, res.headers, res.statusCode), errorAge); | ||
} | ||
return resolvedCallback(null, cacheValueFn(undefined, res.headers, res.statusCode), errorAge); | ||
} | ||
@@ -108,0 +116,0 @@ |
{ | ||
"name": "exp-fetch", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "A small pluggable fetch lib", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git://github.com/ExpressenAB/exp-fetch.git" | ||
"url": "git@github.com:BonnierNews/exp-fetch.git" | ||
}, | ||
@@ -21,8 +21,8 @@ "keywords": [ | ||
], | ||
"author": "AB Kvällstidningen Expressen", | ||
"author": "Bonnier News", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/ExpressenAB/exp-fetch/issues" | ||
"url": "https://github.com/BonnierNews/exp-fetch/issues" | ||
}, | ||
"homepage": "https://github.com/ExpressenAB/exp-fetch", | ||
"homepage": "https://github.com/BonnierNews/exp-fetch", | ||
"devDependencies": { | ||
@@ -32,3 +32,3 @@ "chai": "^4.1.2", | ||
"mocha": "^5.2.0", | ||
"nock": "^9.6.1" | ||
"nock": "^11.9.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "dependencies": { |
fetch | ||
===== | ||
[](https://travis-ci.org/ExpressenAB/exp-fetch) | ||
[](https://travis-ci.org/BonnierNews/exp-fetch) | ||
@@ -5,0 +5,0 @@ A small and pluggable lib to fetch a resource and cache the result. |
@@ -495,2 +495,3 @@ "use strict"; | ||
done(); | ||
return [200, null]; | ||
}); | ||
@@ -568,2 +569,14 @@ fetch(host + path); | ||
describe("error status codes", function () { | ||
it("should pass on the error status code", function (done) { | ||
var fetch = fetchBuilder().fetch; | ||
fake.get(path).reply(500, "Internal Server Error"); | ||
fetch(host + path, function (err) { | ||
should.exist(err); | ||
err.statusCode.should.eql(500); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe("Global header", function () { | ||
@@ -570,0 +583,0 @@ const fetch = fetchBuilder({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
59170
0.9%1441
1.12%77
2.67%