I want to sort the items according to their Id like in ascending so how to do it?
heres the code from react component i used...
import { useState, useEffect} from "react"
//styles
import './ItemList.css'
export default function ItemList() {
const[Items,setItems]=useState([])
useEffect(() => {
fetch('http://localhost:3000/data')
.then(response=>response.json())
.then(json=>setItems(json))
}, [])
console.log(Items)
return (
<div className="item-list">
<h1>Item List</h1>
<ul>
{Items.map(data=>(
<li key={data.id}>
<h2>{data.id}</h2>
<h3>{data.name}</h3>
</li>
))}
</ul>
</div>
)
}
then(json=>setItems(json.sort(....//your sort condition)))