When calling the getInternalTransfert()
method, it is necessary to fetch and display the contents of the svm
variable.
Unfortunately, an error message occurred at the following line:
this.internalTransfertLines = res.TITRE.map(
...
The type '{ svm: number; }[]' cannot be assigned to type 'InternalTransfert[]'.
The object '{ svm: number; }' does not have the required properties such as isin, stock, label, place, among others. (ts(2322))
TS
export class InternalTransfertWatchComponent implements OnInit, OnDestroy {
private unsubscribe$ = new Subject < void > ();
internalTransfertLines: InternalTransfert[] = [];
constructor(private service: InternalTransfertWatchService) {}
ngOnInit(): void {}
ngOnDestroy(): void {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}
getInternalTransfert(): void {
this.service.getInternalTransfert().pipe(
takeUntil(this.unsubscribe$)
).subscribe(res => {
if (res.RETURNCODE === ApiResponseCodeEnum.Ok) {
this.internalTransfertLines = res.TITRE.map(
internalTransfertLine => {
return {
svm: internalTransfertLine.SVM,
}
}
);
}
});
}
}
internal-transfert.response.ts
export interface InternalTransfertResponse extends ApiResponse {
TITRE: {
SVM: number;
ISIN: string;
STOCK: string;
LABEL: string;
PLACE: number;
PLACELABEL: string;
REGR: number;
REGLABEL: string;
DEVISE: string;
} [];
}
internal-transfert.ts
export interface InternalTransfert {
svm: number;
isin: string;
stock: string;
label: string;
place: number;
placelabel: string;
regr: number;
reglabel: string;
devise: string
}
Appreciate any assistance provided