Add component to upload book cover images

This commit is contained in:
2025-10-27 22:51:28 +01:00
parent d407b41c9f
commit 8b8eee8210
11 changed files with 152 additions and 12 deletions

View File

@@ -52,6 +52,23 @@ export function postSignUp(user) {
return genericPostCallNoAuth('/auth/signup', user.value)
}
export function postImage(file) {
const { user } = useAuthStore();
const formData = new FormData();
formData.append('file', file);
if (user != null) {
return fetch(baseUrl + "/upload/cover", {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + user.token
},
body: formData
})
} else {
return Promise.resolve();
}
}
export function genericPostCallNoAuth(apiRoute, object) {
return fetch(baseUrl + apiRoute, {
method: 'POST',