Skip to content
Snippets Groups Projects
Commit c61e42b3 authored by Bernard Roland (Student Com20)'s avatar Bernard Roland (Student Com20)
Browse files

Added an adapter to update a user image

parent a7febc21
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,12 @@ export function updateUser(user: { realname?: string, email?: string }) {
return executeApiPut(`user`, user, () => {}, "Failed to update user");
}
export function updateUserImage(image: File) {
const data = new FormData();
data.append("image", image);
return executeApiPut(`user/image`, data, () => {}, "Failed to update user");
}
export function getUserImageUri(uuid: string): string {
return `${apiRoot}/user/${uuid}/image`;
}
......
......@@ -21,7 +21,11 @@ async function executeApiRequest<T>(path: string, method: string, body: any, onS
method: method,
headers: {
...getAuthHeader(),
...(body ? { 'Content-Type': 'application/json' } : { }),
...(body ? (
body instanceof FormData
? { 'Content-Type': 'multipart/form-data' }
: { 'Content-Type': 'application/json' })
: { }),
},
body: body ? JSON.stringify(body) : undefined,
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment