feat: upload avatar API
This commit is contained in:
17
web/src/api/avatar.ts
Normal file
17
web/src/api/avatar.ts
Normal 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;
|
||||||
|
};
|
Reference in New Issue
Block a user