mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Feat: implement client side functionality for user follow feature
This commit is contained in:
16
src/requests/UserFollow/sendUserFollowRequest.ts
Normal file
16
src/requests/UserFollow/sendUserFollowRequest.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
||||
|
||||
const sendUserFollowRequest = async (userId: string) => {
|
||||
const response = await fetch(`/api/users/${userId}/follow-user`, { method: 'POST' });
|
||||
const json = await response.json();
|
||||
|
||||
const parsed = APIResponseValidationSchema.safeParse(json);
|
||||
|
||||
if (!parsed.success) {
|
||||
throw new Error('Invalid API response.');
|
||||
}
|
||||
|
||||
return parsed;
|
||||
};
|
||||
|
||||
export default sendUserFollowRequest;
|
||||
Reference in New Issue
Block a user