| toc | false |
|---|---|
| comments | true |
| layout | base |
| title | Question Runtime |
| author | Rachit |
| permalink | /qrt |
Fetch Data
<script> document.getElementById('fetchButton').addEventListener('click', function() { const baseURL = "https://codemaxxerbackend.onrender.com/api/questions/course"; const course = "csa"; // Replace with the actual course value const url = `${baseURL}/${course}`; fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/json', }, }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { // Create a table let table = ""; // Insert data into the table data.forEach(item => { table += ``; }); table += "| ID | Question | Answer 1 | Answer 2 | Answer 3 | Answer 4 | Correct Answer | Difficulty | Unit | Points |
|---|---|---|---|---|---|---|---|---|---|
| ${item.id} | ${item.question} | ${item.answer1} | ${item.answer2} | ${item.answer3} | ${item.answer4} | ${item.correctAnswer} | ${item.difficulty} | ${item.unit} | ${item.points} |