mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-17 08:07:51 +00:00
simplify getJson
This commit is contained in:
parent
768138c5b6
commit
1bd0e8966b
@ -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() {
|
||||
|
@ -78,6 +78,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,
|
||||
@ -321,6 +328,7 @@ module.exports = {
|
||||
httpsGet,
|
||||
httpGetJson,
|
||||
httpsGetJson,
|
||||
getJson,
|
||||
hexToNumber,
|
||||
pingEndpoint,
|
||||
decodeParams,
|
||||
|
Loading…
x
Reference in New Issue
Block a user