[Poly > Request] Cleanup a bit of code
This commit is contained in:
parent
36d9a091fd
commit
197f785edf
1 changed files with 2 additions and 7 deletions
|
@ -53,15 +53,10 @@ const request = (...args) => {
|
|||
};
|
||||
}
|
||||
|
||||
console.log('[OpenAsar Request Polyfill]', options.url);
|
||||
|
||||
const listeners = {};
|
||||
|
||||
nodeReq(options).then(async (res) => {
|
||||
const isError = !res.statusCode;
|
||||
|
||||
if (isError) {
|
||||
console.log('[OpenAsar Request Polyfill] Error:', res);
|
||||
if (!res.statusCode) {
|
||||
listeners['error']?.(res);
|
||||
callback?.(res, null, null);
|
||||
|
||||
|
@ -93,7 +88,7 @@ const request = (...args) => {
|
|||
};
|
||||
|
||||
for (const m of [ 'get', 'post', 'put', 'patch', 'delete', 'head', 'options' ]) {
|
||||
request[m] = (url, callback) => request({ url, method: m.toUpperCase() }, callback);
|
||||
request[m] = (url, callback) => request({ url, method: m }, callback);
|
||||
}
|
||||
request.del = request.delete; // Special case
|
||||
|
||||
|
|
Loading…
Reference in a new issue