[Poly > Request] Minor source cleanup
This commit is contained in:
parent
bce146927d
commit
ac009a179e
1 changed files with 2 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue