()
| 9 | // Fetch questions from the backend API |
| 10 | useEffect(() => { |
| 11 | const fetchQuestions = async () => { |
| 12 | try { |
| 13 | const response = await fetch(`${VITE_SERVER_PORT}/api/discussion/getQuestion`); |
| 14 | if (response.ok) { |
| 15 | const data = await response.json(); |
| 16 | setQuestions(data); |
| 17 | } else { |
| 18 | console.error('Failed to fetch questions'); |
| 19 | } |
| 20 | } catch (error) { |
| 21 | console.error('Error fetching questions:', error); |
| 22 | } |
| 23 | }; |
| 24 | |
| 25 | fetchQuestions(); |
| 26 |