mirror of
https://github.com/supabase/supabase.git
synced 2026-06-20 19:16:04 +08:00
* Deprecate use of getWithTimeout, refactor BuildingState and RestoringState to use RQ * Refactor profile-create-mutation to use data/fetchers, and edge-function-status-query to use fetch * Shift post from lib/common/fetch, refactor bucket-object-download-mutation * Address feedback * Minor fix * Smol fix
28 lines
929 B
TypeScript
28 lines
929 B
TypeScript
import type { SupaResponse } from 'types/base'
|
|
import { uuidv4 } from '../../helpers'
|
|
import { constructHeaders, handleError, handleResponse, handleResponseError } from './base'
|
|
|
|
/**
|
|
* @deprecated Please use get method from data/fetchers instead, unless making requests to an external URL
|
|
*/
|
|
export async function get<T = any>(
|
|
url: string,
|
|
options?: { [prop: string]: any }
|
|
): Promise<SupaResponse<T>> {
|
|
const requestId = uuidv4()
|
|
try {
|
|
const { headers: optionHeaders, ...otherOptions } = options ?? {}
|
|
const headers = await constructHeaders(requestId, optionHeaders)
|
|
const response = await fetch(url, {
|
|
method: 'GET',
|
|
referrerPolicy: 'no-referrer-when-downgrade',
|
|
headers,
|
|
...otherOptions,
|
|
})
|
|
if (!response.ok) return handleResponseError(response, requestId)
|
|
return handleResponse(response, requestId)
|
|
} catch (error) {
|
|
return handleError(error, requestId)
|
|
}
|
|
}
|