0

I'm getting this error on Firefox and I'm using rxjs 6.5.4 version:

Unhandled promise rejection TypeError: this.service.getPastData2(...).toPromise().then(...).catch(...).finally is not a function

My code:

lineMap(criteria: ReportCriterionModel){

        this.service
            .getPastData2(
                criteria.deviceIds[0].toString(),
                criteria.vehiclePlates[0].toString(),
                criteria.startDate,
                criteria.finishDate)      
            .toPromise()
            .then(
                (data) => {   
                    this.loadDataToMap(data);  
                    this.filterData = criteria;      
                },
                (err) => {
                    if (err.status == 400) {                    
                        this.isLoadingFms.next(false);
                    }                    
                }
            )
            .catch(
                (err) => {
                    console.log(err);
                }
            )
            .finally(
                () => {                                              
                    this.isLoadingFms.next(false);
                    
                }
            )

    }
May
  • 23
  • 5
  • Are you awaiting the `lineMap()` function anywhere else? Like `let someValue = await this.lineMap(criteria);`? – ruth Mar 09 '22 at 07:43
  • I'm getting this error when i await : await' expressions are only allowed within async functions and at the top levels of modules @ruth – May Mar 09 '22 at 07:47
  • I used this way and it fixed problem: https://stackoverflow.com/a/54115530 – May Mar 09 '22 at 08:18

0 Answers0