export function probeSourceLive(url: string): Promise<string> { return new Promise((resolve, reject) => { uni.request({ url, method: 'HEAD', success: (res) => { const { statusCode } = res; if (statusCode === 200 || String(statusCode).startsWith('3')) { resolve(url); } else { reject(url); } }, fail: () => { reject(url); }, }); }); } export function probeFirstLive(urls: Array<string>): Promise<string> { const array: Array<Promise<string>> = urls.map((item) => { return probeSourceLive(item); }); return Promise.any(array); }
标签:return,url,Promise,reject,export,statusCode,资源,探活 From: https://www.cnblogs.com/zhenjianyu/p/17058121.html