simplify getJson

This commit is contained in:
Iuri Matias 2018-07-08 21:24:19 +03:00
parent 97be8b7463
commit d5f77fb965
2 changed files with 9 additions and 7 deletions

View File

@ -77,14 +77,8 @@ class IPFS {
}
_checkService(cb) {
const self = this;
let url = this._getNodeUrl();
self.logger.info(`Checking IPFS version on ${url}...`);
if (self.protocol !== 'https'){
utils.httpGetJson(url, cb);
} else {
utils.httpsGetJson(url, cb);
}
utils.getJson(url, cb);
}
addProviderToEmbarkJS() {

View File

@ -81,6 +81,13 @@ function httpsGetJson(url, callback) {
});
}
function getJson(url, cb) {
if (url.indexOf('https') === 0) {
return httpsGetJson(url, cb);
}
httpGetJson(url, cb);
}
function pingEndpoint(host, port, type, protocol, origin, callback) {
const options = {
protocolVersion: 13,
@ -363,6 +370,7 @@ module.exports = {
httpsGet,
httpGetJson,
httpsGetJson,
getJson,
hexToNumber,
pingEndpoint,
decodeParams,