Is there a way by which I can optimize the loading time of an api right now the size of the respose is very large, so it takes a lot of time

Below is the sample response data, as you can see the target array varies and can be quite large so it takes a lot of time to load. Sure I can decouple the target array from here and expose another api with pagination just for that. But I am working on a new codebase and in the frontend the target array from the response body is being used in maybe thousands of places. So to expose a new api would be a lot of pain. Does anyone knows a good solution to optimize the laoding time of the api.

{

        "message": "Successfully fetched notification preferences config",
        "data": [
            {
                "id": 0,
                "label": "Star rating",
                "comparators": [
                    {
                        "id": 0,
                        "label": "Contains",
                        "negation": false,
                        "comparator": 1,
                        "function": 0
                    },
                    {
                        "id": 1,
                        "label": "Does not contain",
                        "negation": true,
                        "comparator": 1,
                        "function": 0
                    }
                ],
                "targets": [
                    {
                        "target_id": 0,
                        "target_label": "1 star",
                        "target_value": 1
                    },
                    {
                        "target_id": 1,
                        "target_label": "2 stars",
                        "target_value": 2
                    },
                    {
                        "target_id": 2,
                        "target_label": "3 stars",
                        "target_value": 3
                    },
                    {
                        "target_id": 3,
                        "target_label": "4 stars",
                        "target_value": 4
                    },
                    {
                        "target_id": 4,
                        "target_label": "5 stars",
                        "target_value": 5
                    }
                ]
            },
            {
                "id": 1,
                "label": "Review text",
                "comparators": [
                    {
                        "id": 0,
                        "label": "Is",
                        "negation": false,
                        "comparator": 0,
                        "function": 0
                    },
                    {
                        "id": 1,
                        "label": "Is not",
                        "negation": true,
                        "comparator": 0,
                        "function": 0
                    }
                ],
                "targets": [
                    {
                        "target_id": 0,
                        "target_label": "Present",
                        "target_value": true
                    }
                ]
            },
            {
                "id": 2,
                "label": "Source",
                "comparators": [
                    {
                        "id": 0,
                        "label": "Contains",
                        "negation": false,
                        "comparator": 1,
                        "function": 0
                    },
                    {
                        "id": 1,
                        "label": "Does not contain",
                        "negation": true,
                        "comparator": 1,
                        "function": 0
                    }
                ],
                "targets": [
                    {
                        "target_id": 0,
                        "target_label": "Facebook",
                        "target_value": 0
                    },
                    {
                        "target_id": 3,
                        "target_label": "Google Business",
                        "target_value": 3
                    },
                    {
                        "target_id": 18,
                        "target_label": "Airbnb",
                        "target_value": 18
                    },
                    {
                        "target_id": 5,
                        "target_label": "Yelp",
                        "target_value": 5
                    },
                    {
                        "target_id": 13,
                        "target_label": "Booking",
                        "target_value": 13
                    },
                    {
                        "target_id": 9,
                        "target_label": "Uber Eats",
                        "target_value": 9
                    },
                    {
                        "target_id": 11,
                        "target_label": "Expedia",
                        "target_value": 11
                    },
                    {
                        "target_id": 21,
                        "target_label": "Goibibo",
                        "target_value": 21
                    },
                    {
                        "target_id": 20,
                        "target_label": "Make My Trip",
                        "target_value": 20
                    },
                    {
                        "target_id": 23,
                        "target_label": "Agoda",
                        "target_value": 23
                    },
                    {
                        "target_id": 14,
                        "target_label": "Door Dash",
                        "target_value": 14
                    },
                    {
                        "target_id": 10,
                        "target_label": "Tripadvisor",
                        "target_value": 10
                    },
                    {
                        "target_id": 6,
                        "target_label": "OpenTable",
                        "target_value": 6
                    },
                    {
                        "target_id": 7,
                        "target_label": "Ovation",
                        "target_value": 7
                    },
                    {
                        "target_id": 8,
                        "target_label": "Rewards Network",
                        "target_value": 8
                    },
                    {
                        "target_id": 12,
                        "target_label": "Car Gurus",
                        "target_value": 12
                    },
                    {
                        "target_id": 15,
                        "target_label": "Apartments",
                        "target_value": 15
                    },
                    {
                        "target_id": 16,
                        "target_label": "Siegel Suites",
                        "target_value": 16
                    },
                    {
                        "target_id": 17,
                        "target_label": "Grubhub",
                        "target_value": 17
                    },
                    {
                        "target_id": 19,
                        "target_label": "Rent",
                        "target_value": 19
                    },
                    {
                        "target_id": 22,
                        "target_label": "Zomato",
                        "target_value": 22
                    },
                    {
                        "target_id": 24,
                        "target_label": "Square",
                        "target_value": 24
                    },
                    {
                        "target_id": 25,
                        "target_label": "Hostelworld",
                        "target_value": 25
                    },
                    {
                        "target_id": 26,
                        "target_label": "Resy",
                        "target_value": 26
                    },
                    {
                        "target_id": 27,
                        "target_label": "Choice Hotels",
                        "target_value": 27
                    },
                    {
                        "target_id": 28,
                        "target_label": "Trustpilot",
                        "target_value": 28
                    },
                    {
                        "target_id": 29,
                        "target_label": "Yatra",
                        "target_value": 29
                    },
                    {
                        "target_id": 30,
                        "target_label": "Yellow Pages",
                        "target_value": 30
                    },
                    {
                        "target_id": 31,
                        "target_label": "Better Business Bureau",
                        "target_value": 31
                    },
                    {
                        "target_id": 32,
                        "target_label": "SevenRooms",
                        "target_value": 32
                    },
                    {
                        "target_id": 33,
                        "target_label": "Paytronix",
                        "target_value": 33
                    },
                    {
                        "target_id": 34,
                        "target_label": "SkipTheDishes",
                        "target_value": 34
                    },
                    {
                        "target_id": 35,
                        "target_label": "Swiggy",
                        "target_value": 35
                    },
                    {
                        "target_id": 36,
                        "target_label": "Zillow",
                        "target_value": 36
                    },
                    {
                        "target_id": 43,
                        "target_label": "ESR",
                        "target_value": 43
                    }
                ]
            },
        ]
    }

I tried exposing another api but in the frontend it is a new codebase for me and I will have to make changes in a lot of places for that.
Вернуться на верх