Skip to content

Commit

Permalink
feat: front-end test api call to /api/hello
Browse files Browse the repository at this point in the history
  • Loading branch information
chan9yu committed Jan 15, 2025
1 parent 3317ec9 commit a253fa2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';

import reactLogo from './assets/react.svg';
import './styles/App.css';
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 (
<>
Expand All @@ -23,6 +30,9 @@ export default function App() {
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
<p>
/api/hello: <code>{data}</code>
</p>
</div>
<p className="read-the-docs">Click on the Vite and React logos to learn more</p>
</>
Expand Down

0 comments on commit a253fa2

Please sign in to comment.