mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-04 20:55:19 +02:00
upload
This commit is contained in:
parent
e4de8a39a4
commit
03927a2394
4 changed files with 104 additions and 7 deletions
|
@ -159,7 +159,7 @@ export const actions: Actions = {
|
|||
}
|
||||
formDataToSend.append('rating', rating ? rating.toString() : '');
|
||||
formDataToSend.append('link', link || '');
|
||||
formDataToSend.append('image', image);
|
||||
// formDataToSend.append('image', image);
|
||||
|
||||
// log each key-value pair in the FormData
|
||||
for (let pair of formDataToSend.entries()) {
|
||||
|
@ -233,6 +233,21 @@ export const actions: Actions = {
|
|||
let image_url = new_id.image;
|
||||
let link_url = new_id.link;
|
||||
|
||||
if (image && image.size > 0) {
|
||||
let imageForm = new FormData();
|
||||
imageForm.append('image', image);
|
||||
imageForm.append('adventure', id);
|
||||
let imageRes = await fetch(`${serverEndpoint}/api/images/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Cookie: `${event.cookies.get('auth')}`
|
||||
},
|
||||
body: imageForm
|
||||
});
|
||||
let data = await imageRes.json();
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
return { id, user_id, image_url, link };
|
||||
},
|
||||
edit: async (event) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue