Comparing version 1.4.0 to 1.5.0
@@ -25,3 +25,3 @@ const ErrorWithObject = require('error-with-object'); | ||
try { | ||
rest.body = JSON.parse(rest.body); | ||
rest.body = rest.body !== '' ? JSON.parse(rest.body) : undefined; | ||
} catch (error) { | ||
@@ -28,0 +28,0 @@ return callback(new ErrorWithObject({ |
{ | ||
"name": "callarest", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "rest", |
@@ -41,6 +41,7 @@ const http = require('http'); | ||
}); | ||
response.end(data || JSON.stringify({ | ||
const dataToSend = data != null ? data : JSON.stringify({ | ||
a: 'you said', | ||
b: body | ||
})); | ||
}); | ||
response.end(dataToSend); | ||
}); | ||
@@ -51,3 +52,4 @@ } else { | ||
}); | ||
response.end(data || JSON.stringify({ success: true })); | ||
const dataToSend = data != null ? data : JSON.stringify({ success: true }); | ||
response.end(dataToSend); | ||
} | ||
@@ -54,0 +56,0 @@ }).listen(8000); |
@@ -24,2 +24,19 @@ const test = require('tape'); | ||
test('get -> success if undefined body returned', t => { | ||
t.plan(3); | ||
const server = righto(createJsonServer, ''); | ||
const request = righto(callarestJson, { | ||
url: 'http://localhost:8000' | ||
}, righto.after(server)); | ||
request(function (error, result) { | ||
t.notOk(error); | ||
t.ok(result); | ||
t.deepEqual(result.body, undefined); | ||
destroyServer(); | ||
}); | ||
}); | ||
test('get -> net failure', t => { | ||
@@ -26,0 +43,0 @@ t.plan(3); |
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
12402
323