The issue is that I cannot retrieve data from the Promise, however, I can log it to the console. I need to get the result of 'fetchIntegrationName' function displayed in Breadcrumbs.
type TitleFormatter = (location: { pathname: string }, getState: () => RootState) => Promise<string>;
export interface BreadcrumbItem {
path: string;
title: string | TitleFormatter;
actualPath?: string;
isRootLink?: boolean;
}
const TTNCClientRef: React.MutableRefObject<any> = createRef();
TTNCClientRef.current = createTTNCClient().getIntegrations();
const fetchIntegrationName = async (): Promise<Integration[]> => {
const resp = await TTNCClientRef.current;
const integrationsList = resp.data.content;
return integrationsList[0].name
}
export const buildBreadcrumbDefinitions = ({ solutionId, selectedApplication, solutionName }): ImmutableMap<Record<string, BreadcrumbItem>> =>
Immutable.fromJS({
devicesRoute: {
title: i18n.t('devices.management'),
path: '/devices',
},
integration: {
title: async () => {
await fetchIntegrationName()
.then ((data) => {
console.log(data) // console.logs "Integration apu-test-integration"
return `Integration ${data}` // returns nothing
})
},
path: `/devices/integrations/:integrationId/devices`,
},
} as Record<string, BreadcrumbItem>);