diff --git a/frontend/kubecloud/src/composables/useNodes.ts b/frontend/kubecloud/src/composables/useNodes.ts index dc102482..e669df03 100644 --- a/frontend/kubecloud/src/composables/useNodes.ts +++ b/frontend/kubecloud/src/composables/useNodes.ts @@ -20,6 +20,7 @@ export interface NodeFilters { grid_version?: number region?: string } +const accountIdCache = new Map() export function useNodes() { const nodes = ref([]) @@ -128,8 +129,14 @@ export function useNodes() { // Fetch account id for a twin id async function fetchAccountId(twinId: number): Promise { try { + if(accountIdCache.has(twinId)){ + return accountIdCache.get(twinId)! + } + const response = await userService.getTwinAccount(twinId) - return response.account_id + const accountId = response.account_id + accountIdCache.set(twinId, accountId) + return accountId } catch (err: any) { console.error('Failed to fetch account id:', err) return ''