21 lines
532 B
JavaScript
21 lines
532 B
JavaScript
|
const form = document.getElementById("fishForm");
|
||
|
const image = document.getElementById("fishImage");
|
||
|
|
||
|
form.onsubmit = async (ev) => {
|
||
|
ev.preventDefault();
|
||
|
image.src = "";
|
||
|
try {
|
||
|
const file = document.getElementById("fishFile").files[0];
|
||
|
const arrayBuf = await file.arrayBuffer();
|
||
|
const response = await fetch("/api/fishbowl", {
|
||
|
method: 'POST',
|
||
|
body: arrayBuf,
|
||
|
});
|
||
|
const blob = await response.blob();
|
||
|
image.src = URL.createObjectURL(blob);
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
}
|
||
|
}
|
||
|
|