Files
supabase/packages/common/fetchWrappers.tsx
Terry SuttonandIvan Vasilov de28174c1d Chore/www session consent (#31082)
* Store referrer in session storage until opted-in

* Fix

* Move to common file

* Refactor the useTelemetryCookie hook. Use the hook in www, docs and studio.

* Small fixes.

* Fix all usages of HandlePageTelemetry function.

* Fix type errors.

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2024-12-18 12:02:20 +01:00

25 lines
611 B
TypeScript

interface DataProps {
[prop: string]: any
}
export const post = (url: string, data: DataProps, options = {} as { [key: string]: any }) => {
const { headers: optionHeaders, ...otherOptions } = options
let headers = new Headers({
'Content-Type': 'application/json',
Accept: 'application/json',
...optionHeaders,
})
return fetch(url, {
method: 'POST',
headers,
credentials: 'include',
referrerPolicy: 'no-referrer-when-downgrade',
body: JSON.stringify(data),
...otherOptions,
}).catch((error) => {
console.error('Error at fetchWrapper - post:', error)
})
}