Skip to content

Commit

Permalink
refactor: useUpdateUser supports now image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis3797 committed Jun 13, 2024
1 parent 2b974bb commit 4fda648
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/api/user/mutation/useUpdateUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import { axiosClient } from '../../axiosClient';

type Variables = {
id: string;
body: {
dispname?: string;
avatar_url?: string;
bio?: string;
};
data: FormData;
};

export const useUpdateUser = createMutation<UpdateUserResponse, Variables, AxiosError>({
mutationFn: async (variables) =>
axiosClient({
url: `api/user/${variables.id}/update`,
method: 'PUT',
data: variables.body,
headers: { Authorization: 'Bearer ' + (await AsyncStorage.getItem('accessToken')) },
}).then((response) => response.data),
axiosClient
.put(`api/user/${variables.id}/update`, variables.data, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: 'Bearer ' + (await AsyncStorage.getItem('accessToken')),
},
})
.then((response) => response.data),
});

0 comments on commit 4fda648

Please sign in to comment.