From 3acf230097d43609fba31376540312672fcf3695 Mon Sep 17 00:00:00 2001 From: npy11 Date: Mon, 14 Oct 2024 15:03:33 +0530 Subject: [PATCH] authorised agency js added --- blocks/authorisedagencies/authorisedagencies.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blocks/authorisedagencies/authorisedagencies.js b/blocks/authorisedagencies/authorisedagencies.js index 68ad343c92..8f3dae5ae4 100644 --- a/blocks/authorisedagencies/authorisedagencies.js +++ b/blocks/authorisedagencies/authorisedagencies.js @@ -4,8 +4,12 @@ import { ctaClickInteraction } from '../../dl.js'; export default async function decorate(block) { const cfURL = block.textContent.trim(); const cfRepsonse = await fetchApiCall(cfURL); - const repsonseData = cfRepsonse.data[0].data; - const jsonResponseData = JSON.parse(repsonseData); + const repsonseData = cfRepsonse.data; + const result = Object.groupBy(repsonseData, ({ Location }) => { + const lowercaseLocation = Location.toLowerCase(); + return lowercaseLocation.charAt(0).toUpperCase() + lowercaseLocation.slice(1); + }); + const jsonResponseData = (result); const selectContainerWrapper = createAndAppend('div', '', 'select-container-wrapper'); const selectContainer = createAndAppend('div', '', 'select-container'); const cardContainer = createAndAppend('div', '', 'card-container');