async function submit() { const language = document.getElementById("submission-language").value; const details = document.getElementById("submission-details").value; const code = document.getElementById("submission-code").value; const submission = { problem_id: 2, // TODO validate language and problem id in server language: language, details: details, code: code, }; const response = await fetch("/submission", { method: "post", headers: { "Content-Type": "application/json" }, credentials: "include", body: JSON.stringify(submission) }); console.log(response); const result = await response.json(); console.log(result); } async function init() { const url_params = new URLSearchParams(window.location.search); const problem_id = url_params.get("problem_id"); const response = await fetch(`/problem/${problem_id}`); const problem = await response.json(); const problem_div = document.getElementById("submission-problem"); const title = document.createElement("h2"); title.innerHTML = `Problem: ${problem.title}`; problem_div.appendChild(title); const description = document.createElement("p"); description.innerHTML = problem.description; problem_div.appendChild(description); }