mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Restructure requests directory
This commit is contained in:
28
src/requests/users/profile/sendUpdateUserProfileRequest.ts
Normal file
28
src/requests/users/profile/sendUpdateUserProfileRequest.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import UpdateProfileSchema from '@/services/users/auth/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;
|
||||
Reference in New Issue
Block a user