🍙 added timeout to resolver api request

This commit is contained in:
Shiba 2022-07-27 06:43:58 +00:00
parent de43b990f2
commit 6721966e5b

View file

@ -53,7 +53,12 @@ export async function resolveById(params: Paramaters, progressCallback?: (progre
publicKey
}))
const apiResponse = await fetch(url.toString(), { cache: 'no-store' })
const controller = new AbortController()
// 5 second timeout:
const timeoutId = setTimeout(() => controller.abort(), 5000)
const apiResponse = await fetch(url.toString(), { cache: 'no-store', signal: controller.signal })
clearTimeout(timeoutId)
if (apiResponse.ok) {
const response: ApiResponse = await apiResponse.json()
for (const item of params) {