diff --git a/src/composables/queries/useDistrictsQuery.js b/src/composables/queries/useDistrictsQuery.js index 50868b124..aabe62dc0 100644 --- a/src/composables/queries/useDistrictsQuery.js +++ b/src/composables/queries/useDistrictsQuery.js @@ -29,8 +29,7 @@ const useDistrictsQuery = (queryOptions = undefined) => { return useQuery({ queryKey: [DISTRICTS_QUERY_KEY], - queryFn: () => - orgFetcher(FIRESTORE_COLLECTIONS.DISTRICTS, undefined, isSuperAdmin, administrationOrgs, ['name', 'id', 'tags']), + queryFn: () => orgFetcher(FIRESTORE_COLLECTIONS.DISTRICTS, undefined, isSuperAdmin, administrationOrgs), enabled: isQueryEnabled, ...queryOptions, }); diff --git a/src/helpers/query/orgs.js b/src/helpers/query/orgs.js index edbbcf3a7..f6dd06111 100644 --- a/src/helpers/query/orgs.js +++ b/src/helpers/query/orgs.js @@ -248,7 +248,7 @@ export const orgFetcher = async ( selectedDistrict, isSuperAdmin, adminOrgs, - select = ['name', 'id', 'currentActivationCode'], + select = ['name', 'id', 'tags', 'currentActivationCode'], ) => { if (isSuperAdmin.value) { const axiosInstance = getAxiosInstance(); diff --git a/src/helpers/query/utils.js b/src/helpers/query/utils.js index 5a70336e0..7ff2d9c18 100644 --- a/src/helpers/query/utils.js +++ b/src/helpers/query/utils.js @@ -77,6 +77,17 @@ export const getAxiosInstance = (db = 'admin', unauthenticated = false) => { if (unauthenticated) { delete axiosOptions.headers; } + + // Throw error when the Axios baseUrl is not set. + // This is a temporary solution to ensure the Axios base URL is set before making requests. This is a workaround that + // is required because the initialization logic seems to contain a race condition that causes TanStack to make + // requests before the base URL is set. Throwing an error ensures that TanStack identifies the request as invalid and + // retries it after the base URL is set. + // @TODO: Remove once initialization logic issue is identified and fixed. + if (!axiosOptions.baseURL) { + throw new Error('Base URL is not set.'); + } + return axios.create(axiosOptions); };