Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.on("response", response => {
try {
if (
response.statusCode >= 200 &&
response.statusCode <= 299
) {
resolve(response.pipe(StreamArray.withParser()));
} else {
throw new Error(
`Request failed ${url}, statusCode: ${response.statusCode}`
);
}
} catch (e) {
console.error(e);
reject(e);
}
});
});