-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (24 loc) · 827 Bytes
/
index.js
File metadata and controls
28 lines (24 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
async function query() {
try {
console.log("1")
const response = await fetch("/generate", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ song: document.getElementById("songInput").innerHTML }),
});
console.log("2")
const data = await response.json();
if (response.status !== 200) {
throw data.error || new Error(`Request failed with status ${response.status}`);
}
console.log("3")
document.getElementById("test").innerHTML = data.result
} catch(error) {
// Consider implementing your own error handling logic here
console.log("error caught")
console.error(error);
alert(error.message);
}
}