Files
supabase/studio/lib/common/fetch/patch.ts
T
Joshen Lim 9bc6b8e2ce Chore/make api docs permanent (#18749)
* Make all UI components behind useIsAPIDocsSidePanelEnabled permanent

* Deprecate table editor api side panel component

* Simplify table editor grid code RE API docs button

* Deprecate all old API page and components

* Fix NewProjectPanel

* Clean up Modal component in UI library and add empty state for feature preview

* Reinstate closable prop in Modal, add deprecated comment

* Add deprecate comments for lib/common/fetchers, to use data/fetchers instead
2023-11-07 13:50:34 +08:00

31 lines
955 B
TypeScript

import { constructHeaders, handleError, handleResponse, handleResponseError } from './base'
import { uuidv4 } from '../../helpers'
import { SupaResponse } from 'types/base'
/**
* @deprecated please use patch method from data/fetchers instead
*/
export async function patch<T = any>(
url: string,
data: { [prop: string]: any },
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: 'PATCH',
body: JSON.stringify(data),
referrerPolicy: 'no-referrer-when-downgrade',
headers,
...otherOptions,
})
if (!response.ok) return handleResponseError(response, requestId)
return handleResponse(response, requestId)
} catch (error) {
return handleError(error, requestId)
}
}