To fetch data you can do it like this:
import React, { useState, useEffect } from 'react';
import axios from 'axios';
function App() {
const [data, setData] = useState(null);
useEffect(() => {
const getData = async () => {
const result = await axios('https://route_to_backend.com/bla-bla');
setData(result.data);
}
getData();
}, []);
return (
<ul>
{data && data.map(item => (
<li key={item.id}>
<div>{item.title}</div>
</li>
))}
</ul>
);
}
export default App;
If you provide some example of objects that you receive from server I can write code how you can render it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…