mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
* feat: upgrade via pricing page * reinstall cmdk * fix button size * improve search & autoclose * Update apps/www/lib/fetchWrapper.ts Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com> * Update apps/www/lib/fetchWrapper.ts Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com> * update telemetry events --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
47 lines
998 B
TypeScript
47 lines
998 B
TypeScript
import { getAccessToken } from 'common'
|
|
|
|
interface DataProps {
|
|
[prop: string]: any
|
|
}
|
|
|
|
export async function get(url: string, options?: RequestInit) {
|
|
const accessToken = await getAccessToken()
|
|
|
|
let headers = new Headers({
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
})
|
|
|
|
if (accessToken) {
|
|
headers.set('Authorization', `Bearer ${accessToken}`)
|
|
}
|
|
|
|
return fetch(url, {
|
|
method: 'GET',
|
|
headers,
|
|
referrerPolicy: 'no-referrer-when-downgrade',
|
|
...options,
|
|
})
|
|
}
|
|
|
|
export async function post(url: string, data: DataProps, options?: RequestInit) {
|
|
const accessToken = await getAccessToken()
|
|
|
|
let headers = new Headers({
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
})
|
|
|
|
if (accessToken) {
|
|
headers.set('Authorization', `Bearer ${accessToken}`)
|
|
}
|
|
|
|
return fetch(url, {
|
|
method: 'POST',
|
|
headers,
|
|
referrerPolicy: 'no-referrer-when-downgrade',
|
|
body: JSON.stringify(data),
|
|
...options,
|
|
})
|
|
}
|