I'm encountering an issue when trying to pass a model as a parameter to an API, resulting in the following error:
Type 'string' is not assignable to type 'AVAFModel'.
submitAvafDetails(): Observable<any> {
this.avafBcmsVo = 'avafVO:{' + this.prepareAvafSubmitData() +'}';
return this.httpService.processData('POST', CONSTANTS.API_URL + 'testService.exp', this.avafBcmsVo);
}
The error occurs on this line of code:
this.avafBcmsVo = 'avafVO:{' + this.prepareAvafSubmitData() +'}';
Below is my model structure:
export interface AVAFModel {
bankingDetails: BankingDetails;
digitalAcquisitionsConsent: DigitalAcquisitionsConsent;
employmentDetails: EmploymentDetails;
financeDetails: FinanceDetails;
incomeAndExpenseDetails: IncomeAndExpenseDetails;
personalAddressDetails: PersonalAddressDetails;
personalDetails: PersonalDetails;
vehicleAssetDetails: VehicleAssetDetails;
preQualifiedCustomer: boolean | true;
}
prepareAvafSubmitData() {
const avafBcmsRequestObj: AVAFModel = {
bankingDetails: bankingDetailsVoModel,
digitalAcquisitionsConsent: digitalAcquisitionsConsentVoModel,
employmentDetails: employmentDetailsVoModel,
financeDetails: financeDetailsVoModel,
incomeAndExpenseDetails: incomeAndExpenseDetailsVoModel,
personalAddressDetails: personalAddressDetailsVoModel,
personalDetails: personalDetailsVoModel,
vehicleAssetDetails: vehicleAssetDetailsVoModel,
preQualifiedCustomer: this.getPrequalifiedStatus
};
return avafBcmsRequestObj;
}