forked from VinokurovVE/tests
react cards and stored proc in backend
This commit is contained in:
26
frontend_reactjs/src/App.tsx
Normal file
26
frontend_reactjs/src/App.tsx
Normal file
@ -0,0 +1,26 @@
|
||||
import { useState,useEffect } from 'react'
|
||||
import Card from './components/Card'
|
||||
import axios from 'axios'
|
||||
interface ICard{
|
||||
firstname: string
|
||||
lastname: string
|
||||
email: string
|
||||
}
|
||||
|
||||
function App() {
|
||||
// const data = [
|
||||
// {firstname:"Иван",lastname:"Петров", email:"email@test.ru"},
|
||||
// {firstname:"Алексей",lastname:"Петров", email:"email2@test.ru"},
|
||||
// {firstname:"Василиса",lastname:"Петрова", email:"email3@test.ru"}
|
||||
// ]
|
||||
const [cards, setCards] = useState<ICard[]>([]);
|
||||
useEffect(()=>{axios.get("http://localhost:8000/auth/user/").then((res) =>{setCards(res.data as ICard[]);})},[])
|
||||
console.log(cards)
|
||||
return (
|
||||
<>
|
||||
{cards.map((card, index) => <Card key={index} {...card}/>)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
Reference in New Issue
Block a user