Skip to content

Commit 75a6742

Browse files
committed
fix https request error handling when no callback parameter (promises)
1 parent c4fe659 commit 75a6742

File tree

4 files changed

+6786
-17
lines changed

4 files changed

+6786
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 1.9.1 (2022-06-20)
2+
3+
* Fix https request error handling when no `callback` parameter (promises)
4+
15
### 1.9.0 (2021-12-06)
26

37
* Add methods getOrderListV2, getOrderV2, getOrderV3

lib/BitX.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ BitX.prototype._request = function (method, resourcePath, data, callback) {
107107
})
108108

109109
req.on('error', function (err) {
110-
callback(err)
110+
if (typeof callback === 'function') {
111+
return callback(err)
112+
} else {
113+
return reject(err)
114+
}
111115
})
112116

113117
if (method === 'POST' && data) {

0 commit comments

Comments
 (0)