Error TS2339: The property 'SOLDE' is not found in the 'AdvTitres' type

I am working with an array and need to retrieve the value of the SOLDE variable.

You can find the JSON file here.

When I try to access the SOLDE property, I get the following error message:

error TS2339: Property 'SOLDE' does not exist on type 'AdvTitres'.
<td> {{details.SOLDE}}</td>

internal-transfert-watch.response.ts

export interface InternalTransfertWatchResponse extends ApiResponse {
    TRANS: AdvTitres;
}

export interface AdvTitres {

    TRANS: {
        TITRE: {
            LABEL: string,
            ISIN: string,
            SVM: number,
        },
        SOLDE: number,
        QTE_VENTE: number,
        QTE_BLOQ: number,
        QTE_TRF: number,

    }[];
}

internal-transfert-watch.service.ts

@Injectable()
export class InternalTransfertWatchService {
  private readonly api: string = environment.api;

  constructor(private http: HttpClient, private store: Store) {}

    getTransfert(svm: string): Observable<InternalTransfertWatchResponse> {
      return this.http.post<InternalTransfertWatchResponse>(this.api + `/NEKKYN`, {
        SVM: parseInt(svm)
     
      }, { headers: { AddCustomer: '' } });
    }
    
}

internal-transfert-watch.component.ts

export class InternalTransfertWatchComponent implements OnInit, OnDestroy {
  private unsubscribe$ = new Subject<void>();

  details?: AdvTitres;
  svm: string | null = null;

  constructor(   
    private service: InternalTransfertWatchService,
    private activatedRoute: ActivatedRoute,
    private location: Location,
  ) { }

  ngOnInit(): void {
    this.svm = this.activatedRoute.snapshot.paramMap.get('svm');
  
    if (!this.svm) {
      this.goBack();
      return;
    }
    this.getDetails();
  }

  ngOnDestroy(): void {
    this.unsubscribe$.next();
    this.unsubscribe$.complete();
  }

  private getDetails(): void {
    this.service.getTransfert(this.svm!).pipe(
      takeUntil(this.unsubscribe$)
    ).subscribe(res => {
      if (res.RETURNCODE === ApiResponseCodeEnum.Ok) {
        this.details = res.TRANS;
      

      }
    });
  }


  goBack(): void {
    this.location.back();
  }


}

internal-transfert-watch.component.html

<div class="container" *ngIf="details">
    <table class="table table-hover table-striped spaceLeft">
        <tbody>

            <tr>
                <th>Solde</th>
                <td> {{details.SOLDE}}</td>
            </tr>
        </tbody>
    </table>
</div>

Am I missing a step somewhere?

Answer №1

export interface InternalTransferWatchResponse extends ApiResponse {
  TRANS: Securities[];
}

export interface Securities {

    SECURITY: {
        NAME: string,
        ISIN: string,
        MARKET_VALUE: number,
    },
    BALANCE: number,
    SELL_QUANTITY: number,
    BLOCKED_QUANTITY: number,
    TRANSFER_QUANTITY: number,

}

Answer №2

element, it's important to acknowledge that SOLDE is actually not included in your interface. Instead, it belongs to the TRANS subobject, which means you should access it using the following syntax:
myObj.TRANS.SOLDE

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using masonry-layout with Next Js leads to a ReferenceError stating that window is not defined

Implementing the masonry-layout library by David Desandro in my Next app has been a smooth process. You can find the link here. When I apply it, the masonry layout functions perfectly as intended. Here's how I'm incorporating it successfully: imp ...

Importing styles from an external URL using Angular-cli

How can I load CSS styles from an external URL? For instance, my domain is domain.eu but my site is located at sub.domain.eu. I want to use styles that are stored on the main domain (common for all sites). The example below does not work: "styles&qu ...

Enhancing EventTarget in TypeScript (Angular 2+) for ES5 compilation

Is there a way to create a custom class that extends the EventTarget DOM API class? Let's say we have the following class: class MyClass extends EventTarget { constructor() { super(); } private triggerEvent() { this.dispatchE ...

Angular time-based polling with conditions

My current situation involves polling a rest API every 1 second to get a result: interval(1000) .pipe( startWith(0), switchMap(() => this.itemService.getItems(shopId)) ) .subscribe(response => { console.log(r ...

Leveraging Vue mixin within a @Component

After implementing the vue-property-decorator package, I encountered an issue when trying to use a mixin method inside the beforeRouteEnter hook. Here is what I initially tried: import { Component, Mixins } from 'vue-property-decorator'; import ...

What steps should I take to convert the lazyload module in routes into a regular module?

Software Version: ng version: @angular/cli: 1.0.0-rc.1 node: 6.10.2 os: win32 x64 @angular/common: 4.1.1 @angular/compiler: 4.1.1 @angular/compiler-cli: 4.1.1 @angular/core: 4.1.1 @angular/forms: 4.1.1 @angular/http: 4.1.1 @angular/platform-browser: 4.1.1 ...

What could be the reason for tsc providing such confusing error messages upon revealing transitive implementation types?

In my project, I am dealing with a node module A that relies on another node module B, both of which are written in Typescript. Module B uses bluebird as its Promise implementation and returns Promises to module A. While module B has typings for bluebird, ...

Exciting Update: Next.js V13 revalidate not triggering post router.push

Currently using Next.js version 13 for app routing, I've encountered an issue with the revalidate feature not triggering after a router.push call. Within my project, users have the ability to create blog posts on the /blog/create page. Once a post is ...

The formControl value is not being shown on the display

I am facing an issue with a form that has multiple fields created using formGroup and formControlName. The challenge arises when I launch the application and need to retrieve data from the back end to display it on the view. The specific problem I'm ...

Angular 8 allows for the creation of custom checkboxes with unique content contained within the checkbox itself, enabling multiple selection

I'm in need of a custom checkbox with content inside that allows for multiple selections, similar to the example below: https://i.sstatic.net/CbNXv.png <div class="row"> <div class="form-group"> <input type ...

Personalize the bootstrap classes within Angular app development

I'm currently utilizing bootstrap 4 and sass within my angular 6 application development. My goal is to create a customized nav tab in my application by slightly modifying the bootstrap nav-tabs and nav-link classes. However, the changes I make to th ...

Issue with TypeScript error encountered when attempting to save data locally using React-Redux and LocalStorage

Currently, I am delving into the worlds of React-Redux and TypeScript. Within my small app, I aim to utilize localStorage to store data locally. I attempted to address this based on information from this particular answer, but ran into a TypeScript erro ...

New versions of Angular (2.0.0-beta.17) are experiencing issues with module

Have you encountered any issues with importing modules in the latest version of Angular2? I've noticed that the module names have been updated, for example angular2/core has been changed to @angular/core. Despite this change, I keep getting an error f ...

Enhance your TypeScript skills by leveraging types on the call() method in redux-saga

Is there a way to specify the types of a function using call()? Consider this function: export function apiFetch<T>(url: string): Promise<T> { return fetch(url).then(response => { if (!response.ok) throw new Error(r ...

The browser is not displaying the HTML correctly for the Polymer Paper-Menu component

I attempted to implement a paper-menu, but I am facing issues with the rendered HTML and its interaction. When I click on a menu item, the entire list disappears due to the paper-item elements not being properly placed inside a key div within the paper-men ...

Typescript is throwing an error with code TS2571, indicating that the object is of type 'unknown'

Hey there, I'm reaching out for assistance in resolving a specific error that has cropped up. try{ } catch { let errMsg; if (error.code === 11000) { errMsg = Object.keys(error.keyValue)[0] + "Already exists"; } return res.status ...

Encountering a glitch when attempting to run Bootstrap 4 on an Angular 6 Application

After installing Bootstrap 4 using Angular CLI, I encountered an error when running the application. To resolve this issue, I made changes to the angular.json file: "styles": [ "src/styles.css", "../node_modules/bootstrap/dist/css/bo ...

Improve the way you manage the active selection of a button

ts isDayClicked: { [key: number]: boolean } = {}; constructor() { } setSelectedDay(day: string, index: number): void { switch (index) { case 0: this.isDayClicked[0] = true; this.isDayClicked[1] = false; this.isDay ...

Turn off the interconnected route while utilizing npm to display the tree of dependencies

If I want to display the project's dependencies tree using npm, I would use the following command: npm ls lodash The output will look something like this: > npm ls lodash npm info using [email protected] npm info using [email protected] ...

Angular route fails to load the HTML file

In the process of developing a route within an Angular application, I have successfully implemented 3 routes. However, one particular route is giving me trouble. I have three folders that need to redirect HTML based on the option chosen. In Angular, I cre ...