The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: getWithTimeout
phamhieuda0ee635f6c6
diff --git a/studio/lib/common/fetch/get.ts b/studio/lib/common/fetch/get.tsindex 50d389e23d1..60b0777d129 100644--- a/studio/lib/common/fetch/get.ts+++ b/studio/lib/common/fetch/get.ts@@ -23,3 +23,31 @@ export async function get<T = any>(return handleError(error, requestId)}}++export async function getWithTimeout<T = any>(+ url: string,+ options?: { [prop: string]: any }+): Promise<SupaResponse<T>> {+ const requestId = uuidv4()+ try {+ const timeout = options?.timeout ?? 60000+ const controller = new AbortController()+ const id = setTimeout(() => controller.abort(), timeout)+ const { headers: optionHeaders, ...otherOptions } = options ?? {}+ const headers = constructHeaders(requestId, optionHeaders)+ const response = await fetch(url, {+ method: 'GET',+ credentials: 'include',+ referrerPolicy: 'no-referrer-when-downgrade',+ headers,+ ...otherOptions,+ signal: controller.signal,+ })+ clearTimeout(id)++ if (!response.ok) return handleResponseError(response, requestId)+ return handleResponse(response, requestId)+ } catch (error) {+ return handleError(error, requestId)+ }+}