feat: upload avatar API

This commit is contained in:
2025-06-07 02:10:55 +02:00
parent 70bba15cda
commit 016879b53f

17
web/src/api/avatar.ts Normal file
View File

@ -0,0 +1,17 @@
import { axios, handleApiError } from ".";
export const uploadAvatarApi = async (imageFile: File): Promise<string> => {
const formData = new FormData();
formData.append("image", imageFile);
const response = await axios.put("/api/v1/avatar", formData, {
headers: {
"Content-Type": "multipart/form-data",
},
});
if (response.status !== 200 && response.status !== 201)
throw await handleApiError(response);
return response.data;
};