diff --git a/lib/btc.js b/lib/btc.js index d7c06ce..33f27c0 100644 --- a/lib/btc.js +++ b/lib/btc.js @@ -23,11 +23,16 @@ exports.doBTC = function (req, res) { }); response.on('end', function () { console.log('>> data', data); + let cData = {}; try { - callback(JSON.parse(data), r); - } catch (e) { + cData = JSON.parse(data); + } + catch (e) { console.error(e); } + finally{ + callback(cData, r); + } }); response.on('error', function (e) {