|
1 | | -async function callBackend() { |
2 | | - const output = document.getElementById("output"); |
| 1 | +const container = document.getElementById("roadmap-container"); |
3 | 2 |
|
| 3 | +async function callBackend() { |
4 | 4 | try { |
5 | | - const response = await fetch("https://your-techie.onrender.com/"); |
6 | | - const data = await response.json(); |
| 5 | + const res = await fetch("https://YOUR-BACKEND.onrender.com/"); |
| 6 | + const data = await res.json(); |
7 | 7 |
|
8 | | - output.textContent = JSON.stringify(data, null, 2); |
9 | | - } catch (error) { |
10 | | - output.textContent = "Error connecting to backend: " + error; |
| 8 | + // Example display (adjust if your API returns array) |
| 9 | + container.innerHTML = ` |
| 10 | + <div class="card"> |
| 11 | + <h3>Backend Response</h3> |
| 12 | + <p>${JSON.stringify(data)}</p> |
| 13 | + </div> |
| 14 | + `; |
| 15 | + } catch (err) { |
| 16 | + container.innerHTML = `<p>Error connecting to backend</p>`; |
11 | 17 | } |
12 | 18 | } |
| 19 | + |
| 20 | +function addRoadmap() { |
| 21 | + const name = document.getElementById("name").value; |
| 22 | + const title = document.getElementById("title").value; |
| 23 | + const desc = document.getElementById("description").value; |
| 24 | + |
| 25 | + if (!name || !title || !desc) { |
| 26 | + alert("Fill all fields"); |
| 27 | + return; |
| 28 | + } |
| 29 | + |
| 30 | + const card = ` |
| 31 | + <div class="card"> |
| 32 | + <h3>${title}</h3> |
| 33 | + <p>${desc}</p> |
| 34 | + <small>By ${name}</small> |
| 35 | + </div> |
| 36 | + `; |
| 37 | + |
| 38 | + container.innerHTML += card; |
| 39 | + |
| 40 | + document.getElementById("name").value = ""; |
| 41 | + document.getElementById("title").value = ""; |
| 42 | + document.getElementById("description").value = ""; |
| 43 | +} |
0 commit comments