Skip to content

Commit bb9fef1

Browse files
authored
Add async function to call backend API
1 parent dc66903 commit bb9fef1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

frontend/script.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
async function callBackend() {
2+
const output = document.getElementById("output");
3+
4+
try {
5+
const response = await fetch("https://your-techie.onrender.com/");
6+
const data = await response.json();
7+
8+
output.textContent = JSON.stringify(data, null, 2);
9+
} catch (error) {
10+
output.textContent = "Error connecting to backend: " + error;
11+
}
12+
}

0 commit comments

Comments
 (0)