You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by gl...@apache.org on 2020/02/27 16:10:02 UTC
[couchdb-nano] 08/12: ensure db.head passes the test
This is an automated email from the ASF dual-hosted git repository.
glynnbird pushed a commit to branch axios
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git
commit 6469bf9881e7469a6eb44cd4b6879cdd78352d37
Author: Glynn Bird <gl...@gmail.com>
AuthorDate: Thu Feb 13 20:45:54 2020 +0000
ensure db.head passes the test
---
lib/nano.js | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/nano.js b/lib/nano.js
index 48c89ca..ee76018 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -94,16 +94,17 @@ module.exports = exports = function dbScope (cfg) {
return str
}
const responseHandler = function (response, req, opts, resolve, reject, callback) {
+ const statusCode = response.status || (response.response && response.response.status) || 500
if (response.isAxiosError && response.response) {
response = response.response
}
let body = response.data
- response.statusCode = response.status
+ response.statusCode = statusCode
// let parsed
const responseHeaders = Object.assign({
uri: req.url,
- statusCode: response.statusCode
+ statusCode: statusCode
}, response.headers)
if (!response.status) {
log({ err: 'socket', body: body, headers: responseHeaders })
@@ -130,7 +131,7 @@ module.exports = exports = function dbScope (cfg) {
try { parsed = JSON.parse(body) } catch (err) { parsed = body }
} */
- if (responseHeaders.statusCode >= 200 && responseHeaders.statusCode < 400) {
+ if (statusCode >= 200 && statusCode < 400) {
log({ err: null, body: body, headers: responseHeaders })
if (resolve) {
resolve(body)
@@ -163,9 +164,9 @@ module.exports = exports = function dbScope (cfg) {
}
const errors = errs.merge({
- message: 'couch returned ' + req.statusCode,
+ message: 'couch returned ' + statusCode,
scope: 'couch',
- statusCode: req.statusCode,
+ statusCode: statusCode,
request: req,
headers: responseHeaders,
errid: 'non_200'