async function onSubmit(event: FormSubmitEvent<Schema>) {
const form = new FormData();
const imageUrl = event.data.image_url;
form.set("image_url", imageUrl);
try {
await $fetch(`${config.public.fastApiUrl}/items/`, {
method: "POST",
query: {
name: event.data.name,
types: event.data.types,
quantity: event.data.quantity,
},
body: form,
});
toast.add({
title: "Succes",
description: "Item has been added",
color: "success",
});
} catch (error) {
console.error(error);
toast.add({
title: "Error",
description: "There's an error occured",
color: "error",
});
}
}
async function onSubmit(event: FormSubmitEvent<Schema>) {
const form = new FormData();
const imageUrl = event.data.image_url;
form.set("image_url", imageUrl);
try {
await $fetch(`${config.public.fastApiUrl}/items/`, {
method: "POST",
query: {
name: event.data.name,
types: event.data.types,
quantity: event.data.quantity,
},
body: form,
});
toast.add({
title: "Succes",
description: "Item has been added",
color: "success",
});
} catch (error) {
console.error(error);
toast.add({
title: "Error",
description: "There's an error occured",
color: "error",
});
}
}