Skip to content

Commit 5c18b75

Browse files
author
Glynn Bird
committed
comment why we do body = '' when there is not response body
1 parent ff29111 commit 5c18b75

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/nano.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ module.exports = exports = function dbScope (cfg) {
197197
try {
198198
body = await response.json()
199199
} catch (e) {
200+
// if we were expecting a JSON response but didn't get one, set the body to a blank string
201+
// rather than throw an error. This happens when
202+
// - we do HEAD /db/docid
203+
// - or we get a 500 from CouchDB with no body
204+
// In these cases we expect a rejected promise.
200205
body = ''
201206
}
202207

0 commit comments

Comments
 (0)