Files
the-biergarten-app/src/requests/Account/sendUpdateUserProfileRequest.ts
Aaron William Po fd641c36ab Refactor: begin reorganizing services dir.
- Renamed files and directories to reflect the new structure
- Moved comment-related services to the 'comments' directory
- Moved image-related services to the 'images' directory
- Moved like-related services to the 'likes' directory
- Moved post-related services to the 'posts' directory
- Moved user-related services to the 'users' directory
2023-12-10 14:15:31 -05:00

29 lines
694 B
TypeScript

import UpdateProfileSchema from '@/services/users/User/schema/UpdateProfileSchema';
import { z } from 'zod';
interface UpdateProfileRequestParams {
userId: string;
bio: z.infer<typeof UpdateProfileSchema>['bio'];
}
const sendUpdateUserProfileRequest = async ({
bio,
userId,
}: UpdateProfileRequestParams) => {
const response = await fetch(`/api/users/${userId}/profile/update-profile`, {
method: 'PUT',
body: JSON.stringify({ bio }),
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
throw new Error('Failed to update profile.');
}
const json = await response.json();
return json;
};
export default sendUpdateUserProfileRequest;