mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-06 04:32:40 +00:00
throw new changed to reject
This commit is contained in:
@@ -31,7 +31,7 @@ export async function request(url : string, options? : RequestOpts): Promise<str
|
|||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let data = ''
|
let data = ''
|
||||||
let res = await https_getter(url, options).catch((err) => err as string)
|
let res = await https_getter(url, options).catch((err) => err as string)
|
||||||
if(typeof res === 'string') throw new Error(res)
|
if(typeof res === 'string') {reject(res); return}
|
||||||
if(Number(res.statusCode) >= 300 && Number(res.statusCode) < 400){
|
if(Number(res.statusCode) >= 300 && Number(res.statusCode) < 400){
|
||||||
res = await https_getter(res.headers.location as string , options)
|
res = await https_getter(res.headers.location as string , options)
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ export async function request(url : string, options? : RequestOpts): Promise<str
|
|||||||
export async function request_stream(url : string, options? : RequestOpts): Promise<IncomingMessage>{
|
export async function request_stream(url : string, options? : RequestOpts): Promise<IncomingMessage>{
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let res = await https_getter(url, options).catch((err) => err as string)
|
let res = await https_getter(url, options).catch((err) => err as string)
|
||||||
if(typeof res === 'string') throw new Error(res)
|
if(typeof res === 'string') {reject(res); return}
|
||||||
if(Number(res.statusCode) >= 300 && Number(res.statusCode) < 400){
|
if(Number(res.statusCode) >= 300 && Number(res.statusCode) < 400){
|
||||||
res = await https_getter(res.headers.location as string, options)
|
res = await https_getter(res.headers.location as string, options)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user