[Poly > Request] Minor source cleanup

pull/66/head
Oj 2 years ago
parent bce146927d
commit ac009a179e

@ -1,12 +1,12 @@
const https = require('https');
// Generic polyfill for "request" npm package, wrapper for https
const nodeReq = ({ method, url, headers, qs, timeout, body, stream }) => new Promise((resolve) => {
const nodeReq = ({ method, url, headers, qs, timeout, body }) => new Promise((resolve) => {
let req;
try {
req = https.request(url + (qs != null ? `?${(new URLSearchParams(qs)).toString()}` : ''), { method, headers, timeout }, async (res) => {
const loc = res.headers.location;
if (loc) return resolve(await nodeReq({ url: loc, method, headers, timeout, body, stream }));
if (loc) return resolve(await nodeReq({ url: loc, method, headers, timeout, body }));
resolve(res);
});

Loading…
Cancel
Save