()
| 3 | import './App.css' |
| 4 | |
| 5 | function App() { |
| 6 | const [cards, setCards] = useState([]) |
| 7 | |
| 8 | const fetchData = async () => { |
| 9 | let a = await fetch("https://jsonplaceholder.typicode.com/posts") |
| 10 | let data = await a.json() |
| 11 | setCards(data) |
| 12 | console.log(data) |
| 13 | } |
| 14 | |
| 15 | useEffect(() => { |
| 16 | fetchData() |
| 17 | }, []) |
| 18 | |
| 19 | |
| 20 | return ( |
| 21 | <> |
| 22 | <Navbar/> |
| 23 | <div className="container"> |
| 24 | {cards.map((card)=>{ |
| 25 | return <div key={card.id} className="card"> |
| 26 | <h1>{card.title}</h1> |
| 27 | <p>{card.body}</p> |
| 28 | <span>By: UserId: {card.userId} </span> |
| 29 | </div> |
| 30 | |
| 31 | })} |
| 32 | |
| 33 | </div> |
| 34 | |
| 35 | </> |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | export default App |
nothing calls this directly
no test coverage detected