A
A
Adel Khalitov2019-04-07 22:55:10
JavaScript
Adel Khalitov, 2019-04-07 22:55:10

What is the promise error related to?

getMaterialList() {
    const data = this.myhttp.getHTTP('/getMaterialList').toPromise();
    return data;
}

  async getCalculateInventory(Offer, details) {
    ....
    details['Inventory'] = []
    if (this.isEmpty(this.AllMaterial)) {
      this.AllMaterial = await this.getMaterialList();
    }
  for (let y in this.AllMaterial) {
    if (this.AllMaterial[y].type == 'inventory') {
      var some: any = {};
      ....
      details.Inventory.push(some);
      ....
    }
  }
    ...
    return details;
  }

  getCalculateInventoryToWindow(Offer, details) {
    var InventoryCalculate = this.getCalculateInventory(Offer, details);
        ...
        InventoryCalculate['WindowInventory'] = [];
       ...
        for (let y in this.AllMaterial) {
          if (this.AllMaterial[y].type == 'window') {
            var some: any = {}
            .....
            InventoryCalculate.WindowInventory.push(some);
            ItogMonth = ItogMonth + some.ItogAmortization;
            ItogToStart = ItogToStart + some.Itog;
          }
        }
        InventoryCalculate.material= InventoryCalculate.material + ItogMonth;
        InventoryCalculate.materialToStart = InventoryCalculate.materialToStart + ItogToStart;
        
        return InventoryCalculate;
  }

Property 'WindowInventory' does not exist on type 'Promise<any>'.
Property 'material' does not exist on type 'Promise<any>'.
Property 'material' does not exist on type 'Promise<any>'.
Property 'materialToStart' does not exist on type 'Promise<any>'.
Property 'materialToStart' does not exist on type 'Promise<any>'.

I understand that the error is due to asynchronous functions, but how to avoid errors?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-04-07
@SaveLolliPoP

await forgot
UPD: yes, and async too

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question