diff --git a/lib/nano.js b/lib/nano.js index 75776c2..9ebea4b 100644 --- a/lib/nano.js +++ b/lib/nano.js @@ -197,6 +197,11 @@ module.exports = exports = function dbScope (cfg) { try { body = await response.json() } catch (e) { + // if we were expecting a JSON response but didn't get one, set the body to a blank string + // rather than throw an error. This happens when + // - we do HEAD /db/docid + // - or we get a 500 from CouchDB with no body + // In these cases we expect a rejected promise. body = '' }