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

21 lines
627 B
TypeScript
Raw Normal View History

2024-12-16 20:39:23 +00:00
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
}