Add FastAPI backend and React frontend setup with initial routes and components
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
|
||||
function App() {
|
||||
const [items, setItems] = useState([])
|
||||
|
||||
useEffect(() => {
|
||||
fetch('http://localhost:8000/api/items')
|
||||
.then(response => response.json())
|
||||
.then(data => setItems(data))
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
<h1>React + FastAPI Template</h1>
|
||||
<ul>
|
||||
{items.map((item, index) => (
|
||||
<li key={index}>{item.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
)
|
||||
Reference in New Issue
Block a user