restjs-api
Advanced tools
Comparing version 0.1.2 to 0.1.3
23
index.js
@@ -100,13 +100,18 @@ var request = require("request"); | ||
// send request and wait for its response | ||
request(optionsToUse, function(error, response) { | ||
if (options.stream) { | ||
if (options.stream) return cb(error, response); | ||
// send request and pipe the response | ||
cb(null, request(optionsToUse)); | ||
} else { | ||
cb(error, response ? { | ||
status: response.statusCode, | ||
headers: response.headers, | ||
body: tryParseBodyAsJson(response) | ||
} : null ); | ||
}); | ||
// send request and wait for its response | ||
request(optionsToUse, function(error, response) { | ||
cb(error, response ? { | ||
status: response.statusCode, | ||
headers: response.headers, | ||
body: tryParseBodyAsJson(response) | ||
} : null ); | ||
}); | ||
} | ||
}; | ||
@@ -113,0 +118,0 @@ |
{ | ||
"name": "restjs-api", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Kidozen's connector to invoke REST services", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -88,2 +88,3 @@ var assert = require('assert'); | ||
res.setHeader("x-foo", "bar"); | ||
res.setHeader("Content-Type", "text/baz"); | ||
res.statusCode = 201; | ||
@@ -98,2 +99,3 @@ res.end(); | ||
assert.equal("bar", result.headers["x-foo"]); | ||
assert.equal("text/baz", result.headers["content-type"]); | ||
assert.equal(201, result.statusCode); | ||
@@ -100,0 +102,0 @@ done(); |
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
15838
256