fp/services/next/app/profile/hooks/updateIsUsernamePublic.ts

14 lines
452 B
TypeScript

export type UpdateMetadataInput = { isUsernamePublic: boolean }
export async function updateIsUsernamePublic (data: UpdateMetadataInput): Promise<any> {
const res = await fetch('/api/user/metadata', {
method: 'POST',
body: JSON.stringify({
isUsernamePublic: data.isUsernamePublic
})
})
const d = await res.json()
if (!res.ok) throw new Error(`failed to updateIsUsernamePublic. ${res.status} ${res.statusText}`);
return d
}