Skip to content

Commit 112ca9a

Browse files
committed
update
1 parent bbc3bc2 commit 112ca9a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/configuration/apiConfiguration.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@ export class DefaultApiConfiguration implements ApiConfiguration {
7777
return stateMachine;
7878
}
7979

80+
8081
private findStateByCode(stateMachine: StateMachine, stateCode: number): State {
81-
const statesArray = stateMachine.states[0]?.State;
82+
const stateContainer = stateMachine.states[0];
83+
const statesArray = Array.isArray(stateContainer?.State)
84+
? stateContainer.State
85+
: stateContainer?.State
86+
? [stateContainer.State]
87+
: [];
8288

83-
if (!statesArray) {
84-
throw new Error(`State '${stateCode}' not found`);
85-
}
89+
const result = statesArray.find(state => Number(state.id) === stateCode);
8690

87-
const result = statesArray.find(state => Number(state.attributes.id) === stateCode);
8891
if (!result) {
8992
throw new Error(`State '${stateCode}' not found`);
9093
}

0 commit comments

Comments
 (0)