Sep 4, 2023
0
Level 4
How and where to build an object from API data?
I get some data from an API, I then label each piece of data and assign an icon in my front end. So far, I've elected to do this in a composable:
export function useStats(data) {
const stats = [
{
title: 'Series',
value: data.series,
icon: SeriesSCircleIcon
},
{
title: 'Age',
value: data.age,
icon: CheckCircleIcon,
},
{
title: 'On Sale',
value: data.is_on_sale,
icon: CheckSquareIcon,
},
{
title: 'Used',
value: data.used,
icon: UsedSquareIcon,
},
......
This doesn't seem right? Where is a better place to build this object? note that there are 10-20 stats.
Please or to participate in this conversation.