I created 2 new Objects in for loop, which they have almost similar value (Languague, PlantCode, CreationTime ). How could I adjust it better?
for (let entry of data) {
const objectA: Information = {
language: 'de',
statusCode: entry['ec_Status'].statusMain + ':' + entry['ec_Status'].statusAdditional,
plantCode: entry['ec_ControlType'],
creationTime: entry['creationTime'],
type: 'status',
};
const objectB: Information = {
language: 'de',
statusCode: entry['ec_Status'].infoMain + ':' + entry['ec_Status'].infoAdditional,
plantCode: entry['ec_ControlType'],
creationTime: entry['creationTime'],
type: 'information',
};
await this.deviceStatusInformationService.getStatustext(objectA);
await this.deviceStatusInformationService.getStatustext(objectB);
and I defined Information like that:
export interface Information {
plantCode: number;
statusCode: string;
language: string;
text?: string;
subtext?: string;
creationTime: Date;
type: 'status' | 'information';
}