SaveLolliPoP
@SaveLolliPoP
1 / 0 = ∞

С чем связана ошибка promice?

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>'.


Я понимаю что ошибка происходит из за асинхронных функций, но как избежать ошибок?
  • Вопрос задан
  • 100 просмотров
Решения вопроса 1
@StockholmSyndrome
await забыли
var InventoryCalculate = await this.getCalculateInventory(Offer, details);

UPD: да и async тоже
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 05:01
999999 руб./за проект
19 апр. 2024, в 03:52
1000 руб./за проект
19 апр. 2024, в 03:01
1000 руб./за проект