Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

panthro's avatar

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.

0 likes
0 replies

Please or to participate in this conversation.