I have a RestApi that sends me the response in Json Format with an address object containing fields such as address1, address2, city, etc. To handle this, I defined an interface within my application to outline these objects:
export interface ISurveyResponseDetail {
docID?: string;
permission?: string;
property?: IProperty;
surveyID?: string;
}
export interface IProperty {
address1?: string;
address2?: string;
city?: string;
state?: string;
zip?: string;
In my TypeScript file, I am looking to utilize a data adapter to map the response into this interface. However, I am unsure of how to properly assign and use the property Object of type IProperty with the values:
static adaptSurveyResponseDetail(data): ISurveyResponseDetail {
if (data) {
return {
property:
// address1 _.get(data, 'property.address1', null),
// city _.get(data, 'property.city', null),
docID: _.get(data, 'docID', null),
permission: _.get(data, 'permission', null),
surveyID: _.get(data, 'survey_id', null),
};
} else {
return data;
}
}