skip to Main Content

adding only 10 first objects to my array from an api that returns an array of 250 objects – Javascript

hey guys I have an api call that returns an array of 250 objects but I only want the first 10 objects stored in my array useEffect(()=>{ fetch('https://tennis-live-data.p.rapidapi.com/rankings/ATP', options) .then(response => response.json()) .then(response => { for(let i=0;i<10;i++){ setTop10([...top10, response.results.rankings[i]]) }…

VIEW QUESTION
Back To Top
Search