Skip to content

Commit

Permalink
allow both uppercase and lowercase in model metadata response (#12458)
Browse files Browse the repository at this point in the history
* allow both uppercase and lowercase in model metadata response

* keep the hack internal to the query
  • Loading branch information
nkylstad authored Mar 7, 2024
1 parent 974d961 commit 8817b7d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ export const useDatamodelMetadataQuery = (
queryFn: () =>
getDatamodelMetadata(org, app, layoutSetName).then((res) => {
const dataModelFields: DatamodelFieldElement[] = [];
Object.keys(res.elements).forEach((dataModelField) => {

// Hack because we don't know if the response is upper or lower cased. Should be reverted once
// https://github.com/Altinn/altinn-studio/pull/12457 is ready, this should fix the issue in the API.
const response = res as unknown as any;
const elements = response.elements || response.Elements; // End of hack.

Object.keys(elements).forEach((dataModelField) => {
if (dataModelField) {
dataModelFields.push(res.elements[dataModelField]);
dataModelFields.push(elements[dataModelField]);
}
});
return dataModelFields;
Expand Down

0 comments on commit 8817b7d

Please sign in to comment.