I am currently working on creating a class that will enable sending a JSON object to a REST API. The JSON object that needs to be sent is as follows:
{
"libraryName": "temp",
"triggerName": "trigger",
"currentVersion": "1.3",
"createdUser": "xyz",
"visibilityType": "private",
"WFAllowdTeam": {
"allowedTeam": "team1"
},
"WFLibraryHistory": {
"createdDate": "2016-7-7T05:10:04.106Z",
"modifiedDate": "2016-7-9T05:10:04.106Z"
}
}
I attempted to create a class and set the data by initializing the object like
this.library.WFAllowdTeam.WFAllowdTeam = 'team';
. You can see the class I created below:
class WFLibraryHistory {
public createdDate: any;
public modifiedDate: any;
}
class WFAllowdTeam {
public WFAllowdTeam: string;
}
export class Library {
public libraryName: string;
public triggerName: string;
public currentVersion: string;
public createdUser: string;
public visibilityType: string;
public libraryID: string;
WFLibraryHistory: WFLibraryHistory;
WFAllowdTeam: WFAllowdTeam;
}
The error message encountered is as follows:
platform-browser.umd.js:937 TypeError: Cannot set property 'WFAllowdTeam' of undefined
at WFLibraryComponentAddNewWorkflow.createWorkflow (wf-library.component.new.workflow.ts:47)
at DebugAppView._View_WFLibraryComponentAddNewWorkflow0._handle_click_61_0 (WFLibraryComponentAddNewWorkflow.ngfactory.js:488)
at eval (core.umd.js:12718)
at SafeSubscriber.schedulerFn [as _next] (core.umd.js:9181)
at SafeSubscriber.__tryOrUnsub (Subscriber.ts:240)
at SafeSubscriber.next (Subscriber.ts:192)
at Subscriber._next (Subscriber.ts:133)
at Subscriber.next (Subscriber.ts:93)
at EventEmitter.Subject._finalNext (Subject.ts:154)
at EventEmitter.Subject._next (Subject.ts:144)
Any guidance or assistance in resolving this issue would be greatly appreciated.