glynnbird commented on code in PR #314:
URL: https://github.com/apache/couchdb-nano/pull/314#discussion_r1842235682


##########
lib/nano.js:
##########
@@ -168,29 +163,48 @@ module.exports = exports = function dbScope (cfg) {
     delete responseHeaders.server
     delete responseHeaders['content-length']
 
-    /* if (opts.dontParse) {
-      parsed = body
-    } else {
-      try { parsed = JSON.parse(body) } catch (err) { parsed = body }
-    } */
-
     if (statusCode >= 200 && statusCode < 400) {
-      log({ err: null, body, headers: responseHeaders })
-      if (resolve) {
-        resolve(body)
+      // collect response
+      const ct = response.headers.get('content-type')
+      let retval = ''
+      if (ct === 'application/json') {
+        try {
+          retval = await response.json()
+        } catch {
+          // do nothing

Review Comment:
   Yeah. I tried that but some tests fail. The tests (and presumably the users) 
are expecting an rejected promise not a thrown exception. This would apply to 
500 responses (where we are expecting JSON back but get nothing) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to