The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add head method
Joshen Lima7d930b6f37a
diff --git a/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx b/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsxindex 2301caeea8b..8c92547da6b 100644--- a/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx+++ b/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx@@ -11,7 +11,7 @@ import {import { useStore } from 'hooks'import { API_URL } from 'lib/constants'-import { get } from 'lib/common/fetch'+import { get, head } from 'lib/common/fetch'import Table from 'components/to-be-cleaned/Table'const PAGE_LIMIT = 10@@ -35,15 +35,16 @@ const InvoicesSettings: FC<Props> = ({ organization }) => {useEffect(() => {let cancel = falseconst fetchInvoiceCount = async () => {- const res = await get(`${API_URL}/stripe/invoices?customer=${stripe_customer_id}&count=true`)- if (!cancel) {- console.log('fetchInvoiceCount', res)- if (res.error) {- ui.setNotification({ category: 'error', message: res.error.message })- } else {- setCount(res.count)- }- }+ const res = await head(`${API_URL}/stripe/invoices?customer=${stripe_customer_id}`)+ console.log('fetchInvoiceCount', res)+ // if (!cancel) {+ // console.log('fetchInvoiceCount', res)+ // if (res.error) {+ // ui.setNotification({ category: 'error', message: res.error.message })+ // } else {+ // setCount(res.count)+ // }+ // }}fetchInvoiceCount()@@ -52,7 +53,6 @@ const InvoicesSettings: FC<Props> = ({ organization }) => {}}, [stripe_customer_id])- // [For Hieu] Followed by fetching the invoices themselvesuseEffect(() => {let cancel = falsediff --git a/studio/lib/common/fetch/head.ts b/studio/lib/common/fetch/head.tsnew file mode 100644index 00000000000..ed81cfa5b68--- /dev/null+++ b/studio/lib/common/fetch/head.ts@@ -0,0 +1,31 @@+import { handleError, handleResponse, handleResponseError, constructHeaders } from './base'+import { uuidv4 } from '../../helpers'+import { SupaResponse } from 'types/base'++export async function head<T = any>(+ url: string,+ options?: { [prop: string]: any }+): Promise<SupaResponse<T>> {+ const requestId = uuidv4()+ try {+ const { headers: optionHeaders, ...otherOptions } = options ?? {}+ const headers = constructHeaders(requestId, optionHeaders)+ const response = await fetch(url, {+ method: 'HEAD',+ credentials: 'include',+ referrerPolicy: 'no-referrer-when-downgrade',+ headers,+ ...otherOptions,+ })+ console.log(+ 'HEAD',+ response.headers,+ response.headers.keys(),+ response.headers.get('X-Total-Count')+ )+ if (!response.ok) return handleResponseError(response, requestId)+ return handleResponse(response, requestId)+ } catch (error) {+ return handleError(error, requestId)+ }+}diff --git a/studio/lib/common/fetch/index.ts b/studio/lib/common/fetch/index.tsindex 7303609a9ba..5944b4d0b17 100644--- a/studio/lib/common/fetch/index.ts+++ b/studio/lib/common/fetch/index.ts@@ -3,3 +3,4 @@ export * from './delete'export * from './get'export * from './patch'export * from './post'+export * from './head'