mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 01:40:13 -04:00
ed207751ad
* Update telemetry calls for docs to support PH * Update telemetry calls for www to support PH * Add ts ignore * Remove use of useRouter for docs * Add credentials include for www and docs for telemetry calls * Update TELEMETRY_CONSENT in common for www and docs to reset telemetry opt in preference * Update common telemetry to use new endpoint and payload, and trigger reset request when opting out of telemetry from ui patterns PrigacySettings * Fix * Fix * Fix * Fix build issue in docs * Fix build issue in docs * I hope this fixes the build issues * once more... * Fix * Add credentials include * Fix
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
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 { headers: optionHeaders, ...otherOptions } = options || {}
|
|
const accessToken = await getAccessToken()
|
|
|
|
let headers = new Headers({
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
...optionHeaders,
|
|
})
|
|
|
|
if (accessToken) {
|
|
headers.set('Authorization', `Bearer ${accessToken}`)
|
|
}
|
|
|
|
return fetch(url, {
|
|
method: 'POST',
|
|
headers,
|
|
credentials: 'include',
|
|
referrerPolicy: 'no-referrer-when-downgrade',
|
|
body: JSON.stringify(data),
|
|
...otherOptions,
|
|
})
|
|
}
|