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

14 lines
452 B
TypeScript
Raw Normal View History

2024-12-12 07:23:46 +00:00
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
}