Skip to content

Commit 9c51b92

Browse files
Brad VogelBrad Vogel
authored andcommitted
Support DELETE operations by not throwing an error when an empty body is passed and also supporting an empty response.
1 parent 7675294 commit 9c51b92

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/batchelor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var request = require('request'),
100100
// Set Defaults
101101
options.method = options.method || 'GET';
102102
options.requestId = requestId;
103-
if (options.method !== 'GET') {
103+
if (options.method === 'POST') {
104104
// It's not a GET so we need something to push
105105
if (!options.parameters) {
106106
throw new Error('when using POST: options.parameters is required');
@@ -211,7 +211,9 @@ var request = require('request'),
211211
part.data = parser.parseResponse(part.data.toString());
212212

213213
// Parse response JSON
214-
part.data.body = JSON.parse(part.data.body);
214+
if (part.data.body) {
215+
part.data.body = JSON.parse(part.data.body);
216+
}
215217

216218
// Get the response id if exists
217219
var returnedContentId = part.header['content-id'],

0 commit comments

Comments
 (0)