同步发送fetch请求,支持设置不启用超时
This commit is contained in:
parent
db715f7356
commit
a4fe54f056
|
|
@ -38,6 +38,9 @@ function verify(publicKey, body, ts, nonce, signature) {
|
|||
return verify2.verify(publicKey, signature, 'hex');
|
||||
}
|
||||
async function fetchWithTimeout(url, options, timeout = 5000) {
|
||||
if (typeof AbortController === 'undefined' || timeout === 0) {
|
||||
return fetch(url, options);
|
||||
}
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
// 设置超时
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ function verify(publicKey: string, body: string, ts: string, nonce: string, sign
|
|||
}
|
||||
|
||||
async function fetchWithTimeout(url: string, options: RequestInit, timeout = 5000) {
|
||||
if (typeof AbortController === 'undefined' || timeout === 0) {
|
||||
return fetch(url, options);
|
||||
}
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue