From a253fa23a97d6b92a8616b1ff6ff23401f39ec33 Mon Sep 17 00:00:00 2001 From: chan9yu Date: Wed, 15 Jan 2025 21:14:39 +0900 Subject: [PATCH] feat: front-end test api call to /api/hello --- frontend/src/App.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index ed0b6b3..bff80b1 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import reactLogo from './assets/react.svg'; import './styles/App.css'; @@ -6,6 +6,13 @@ import viteLogo from '/vite.svg'; export default function App() { const [count, setCount] = useState(0); + const [data, setData] = useState(''); + + useEffect(() => { + fetch(`${import.meta.env.VITE_API_SERVER}/api/hello`) + .then(response => response.json()) + .then(data => setData(JSON.stringify(data))); + }, []); return ( <> @@ -23,6 +30,9 @@ export default function App() {

Edit src/App.tsx and save to test HMR

+

+ /api/hello: {data} +

Click on the Vite and React logos to learn more