Skip to content
This repository was archived by the owner on Feb 20, 2021. It is now read-only.

Commit 06a853d

Browse files
Fix superagent (#37)
1 parent 93ee627 commit 06a853d

5 files changed

Lines changed: 28 additions & 323 deletions

File tree

lib/bcypher.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,17 @@ module.exports = Blockcy;
3030
Blockcy.prototype._get = function (url, params, cb) {
3131
var urlr = URL_ROOT + this.coin + '/' + this.chain + url;
3232
params = Object.assign({}, params, { token: this.token });
33-
request.get({
34-
url: urlr,
35-
strictSSL: true,
36-
json: true,
37-
qs: params
38-
}, function (error, response, body) {
39-
if (error || response.statusCode !== 200) {
40-
cb(error, body || {});
41-
} else {
42-
cb(null, body);
43-
}
44-
});
33+
request
34+
.get(urlr)
35+
.set('Accept', 'application/json')
36+
.query(params)
37+
.end(function (error, response) {
38+
if (error || response.statusCode !== 200) {
39+
cb(error || {});
40+
} else {
41+
cb(null, response.body);
42+
}
43+
});
4544
};
4645

4746
/**
@@ -58,19 +57,18 @@ Blockcy.prototype._get = function (url, params, cb) {
5857
Blockcy.prototype._post = function (url, params, data, cb) {
5958
var urlr = URL_ROOT + this.coin + '/' + this.chain + url;
6059
params = Object.assign({}, params, { token: this.token });
61-
request.post({
62-
url: urlr,
63-
strictSSL: true,
64-
json: true,
65-
qs: params,
66-
body: data
67-
}, function (error, response, body) {
68-
if (error || (response.statusCode !== 200 && response.statusCode !== 201)) {
69-
cb(error, body || {});
70-
} else {
71-
cb(null, body);
72-
}
73-
});
60+
request
61+
.post(urlr)
62+
.set('Content-Type', 'application/json')
63+
.query(params)
64+
.send(data)
65+
.end(function (error, response) {
66+
if (error || (response.statusCode !== 200 && response.statusCode !== 201)) {
67+
cb(error || {});
68+
} else {
69+
cb(null, response.body);
70+
}
71+
});
7472
};
7573

7674
/**

0 commit comments

Comments
 (0)