Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 671 Bytes

resources.md

File metadata and controls

29 lines (23 loc) · 671 Bytes

Making API Call with Hooks

Add this code to Format the data that we got in the API Response

const {data} = apiResponse
const formattedLeaderboardData = data.leaderboard_data.map(eachUser => ({
  id: eachUser.id,
  rank: eachUser.rank,
  name: eachUser.name,
  profileImgUrl: eachUser.profile_image_url,
  score: eachUser.score,
  language: eachUser.language,
  timeSpent: eachUser.time_spent,
}))

Add this code to render LeaderboardTable

return <LeaderboardTable leaderboardData={formattedLeaderboardData} />

Add this code to render failure view

const {errorMsg} = apiResponse
return <ErrorMessage>{errorMsg}</ErrorMessage>