mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-17 09:46:37 +00:00
simplify getJson
This commit is contained in:
parent
97be8b7463
commit
d5f77fb965
@ -77,14 +77,8 @@ class IPFS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_checkService(cb) {
|
_checkService(cb) {
|
||||||
const self = this;
|
|
||||||
let url = this._getNodeUrl();
|
let url = this._getNodeUrl();
|
||||||
self.logger.info(`Checking IPFS version on ${url}...`);
|
utils.getJson(url, cb);
|
||||||
if (self.protocol !== 'https'){
|
|
||||||
utils.httpGetJson(url, cb);
|
|
||||||
} else {
|
|
||||||
utils.httpsGetJson(url, cb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addProviderToEmbarkJS() {
|
addProviderToEmbarkJS() {
|
||||||
|
@ -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) {
|
function pingEndpoint(host, port, type, protocol, origin, callback) {
|
||||||
const options = {
|
const options = {
|
||||||
protocolVersion: 13,
|
protocolVersion: 13,
|
||||||
@ -363,6 +370,7 @@ module.exports = {
|
|||||||
httpsGet,
|
httpsGet,
|
||||||
httpGetJson,
|
httpGetJson,
|
||||||
httpsGetJson,
|
httpsGetJson,
|
||||||
|
getJson,
|
||||||
hexToNumber,
|
hexToNumber,
|
||||||
pingEndpoint,
|
pingEndpoint,
|
||||||
decodeParams,
|
decodeParams,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user