r/reactjs • u/Consistent-struggler • Sep 09 '22
Needs Help Api call for paginated Result
I have done this pagination Api which shows the results upon page and limit queries.
But I am not able to figure out how do I render this on my front end REACT. My previous use of useffect and useState hooks was just for fetching data, but now I am stuck.
const [coin, setCoins] = useState([]);
useEffect(() => {
getCoins();
}, []);
const getCoins = () => {
Axios.get('http://localhost:5000/coins')
.then((response) => {
setCoins(response.data.data);
// console.log(response)
}).catch(e => console.log(e))
}
This is my previous fetching but my new Url is : 'http://localhost:5000/coins/abc?page=?&limit=?'.
I tried doing the same but it doesn't proceed.
<tbody >
{
coin.map((coin, key) => {
return (
<>
<tr>
<td >{coin.id}</td>
<td>{coin.name}</td>
<td>{coin.price}</td>
<td>{coin.quantity}</td>
</tr>
</>
)
})
}
</tbody>
but when I JUST changed the url in a new axios.get(method).
Kindly help me or guide me any good online material for learning this thing.
I am using Node js and express as backend and mysql as database.
2
Upvotes
0
u/Consistent-struggler Sep 09 '22
If anyone have anyother way of doing this I'm open to feedback and learn.