mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
21 lines
506 B
JavaScript
21 lines
506 B
JavaScript
const http = require('http')
|
|
const https = require('https')
|
|
const { URL } = require('url')
|
|
|
|
|
|
module.exports = {
|
|
http,
|
|
https,
|
|
getRequest: (options, cb) => {
|
|
let protocol = 'http:'
|
|
|
|
if(typeof options === 'string'){
|
|
const url = new URL(options)
|
|
protocol = url.protocol
|
|
} else if(options.protocol){
|
|
protocol = options.protocol
|
|
}
|
|
|
|
return protocol === 'http:' ? http.request(options, cb) : https.request(options, cb)
|
|
}
|
|
} |