refactor: revert prior
This commit is contained in:
parent
90e32a454d
commit
760cc2d718
1 changed files with 2 additions and 4 deletions
|
@ -29,10 +29,8 @@ export function simpleReq(
|
||||||
return new Promise<IncomingMessage>((resolve, reject) => {
|
return new Promise<IncomingMessage>((resolve, reject) => {
|
||||||
get(url, options, res => {
|
get(url, options, res => {
|
||||||
const { statusCode, statusMessage, headers } = res;
|
const { statusCode, statusMessage, headers } = res;
|
||||||
if (statusCode && statusCode >= 400) return reject(new Error(`${statusCode}: ${statusMessage} - ${url}`));
|
if (statusCode! >= 400) return void reject(`${statusCode}: ${statusMessage} - ${url}`);
|
||||||
if (statusCode && statusCode >= 300 && headers.location) {
|
if (statusCode! >= 300) return simpleReq(headers.location!, options).then(resolve).catch(reject);
|
||||||
return simpleReq(headers.location, options).then(resolve).catch(reject);
|
|
||||||
}
|
|
||||||
resolve(res);
|
resolve(res);
|
||||||
}).on("error", err => {
|
}).on("error", err => {
|
||||||
if (retries > 10) {
|
if (retries > 10) {
|
||||||
|
|
Reference in a new issue