How to update an object key for each irritation in the Api response

Using this Methode for each item if we have different key values, we can get the start with letters and change the key to the objects for all the item details.

 if (itemImagesDetail) {
                        for (const key in itemImagesDetail) {
                            if (itemImagesDetail.hasOwnProperty(key) && key.startsWith('FM')) {
                                const imageid = itemImagesDetail[key];
                                const newKey = 'imageid'; 
                                delete itemImagesDetail[key];
                                itemImagesDetail[newKey] = imageid;
                            }
                        }
                    }

Leave a comment

Your email address will not be published. Required fields are marked *