Something is not right here:
let organization = organizationList2[context.params?.organizationId];
Failed to compile.
./pages/[lang]/designer/[organizationId].tsx:337:40
Type error: Type 'string[]' cannot be used as an index type.
335 | });
336 | let organizationList2 = await organizationList2Data.json();
> 337 | let organization = organizationList2[context.params?.organizationId];
Curious why rganization
is undefined
.
organizationList2 {
'EC763372-277D-46B9-AD87-F45519E7D606': {
name: 'TADA moment',
events: { 'tada-moment-asztalivaza': [Object] }
},
...
}
context.params?.organizationId 7181fdc7-a58e-45b1-a377-a21e4c62442c
oraganization undefined
and organizationId
:
let organizationId: string = context.params?.organizationId as string;
and the entire method:
export const getStaticProps: GetStaticProps = async ({ ...context }) => {
let organizationList2Data = await fetch(`${baseURL}getSMOrganizations`, {
method: "post",
headers: { "Content-Type": "application/json" },
});
let organizationList2 = await organizationList2Data.json();
let organization = organizationList2[context.params?.organizationId];
console.log("organizationList2", organizationList2);
console.log("context.params?.organizationId", context.params?.organizationId);
console.log("oraganization", organization);
let zz = Object.keys(organizationList2);
console.log("zz", zz);
let organizationId: string = context.params?.organizationId as string;
return {
props: {
organizationId: context.params?.organizationId,
organization: organization ?? "",
},
revalidate: 600,
};
};