Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.read = (uri) => {
let parsedUrl = url.parse(uri, false, true);
let makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
let serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
let agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
let options = {
host: parsedUrl.host,
path: parsedUrl.path,
agent: agent,
port: serverPort,
method: 'GET',
headers: { 'Content-Type': 'application/json' },
};
return new Promise((resolve, reject) => {
let req = makeRequest(options, (response) => {
let data = '';