Skip to content

Commit

Permalink
comment why we do body = '' when there is not response body
Browse files Browse the repository at this point in the history
  • Loading branch information
Glynn Bird committed Nov 14, 2024
1 parent ff29111 commit 5c18b75
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/nano.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
}

Expand Down

0 comments on commit 5c18b75

Please sign in to comment.