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

21 lines
627 B
TypeScript

import { configs } from "@/app/config/configs";
export type UpdateIsUsernamePublicInput = {
isUsernamePublic: boolean;
access_token: string;
}
export async function updateIsUsernamePublic (data: UpdateIsUsernamePublicInput): Promise<any> {
console.log(`upadateIsUernamePublic configs.nextUrl=${configs.nextUrl}`)
const res = await fetch(`${configs.nextUrl}/api/profile`, {
method: 'POST',
body: JSON.stringify({
username_visibility: data.isUsernamePublic
})
})
const d = await res.json()
if (!res.ok) throw new Error(`failed to updateProfile. ${res.status} ${res.statusText}`);
return d
}