document.getElementById("upload-form").addEventListener("submit", event => { event.preventDefault(); const data = new FormData(event.target); fetch("/api/upload-video", { method: "POST", body: data, }) .then(response => response.json()) .then(response => { if (!response.ok) { error(response.error); return; } location.href = "/queue"; }) .catch(err => { error("failed to upload video"); }); });