18 lines
463 B
TypeScript
18 lines
463 B
TypeScript
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;
|
|
};
|