L
L
lzy2019-07-09 19:54:52
Angular
lzy, 2019-07-09 19:54:52

Why is the cycle repeated several times?

Hello, I need to display data, but there was a problem, the cycle repeats several times, please tell me how to fix it. I understand that fetch and map create a cycle separately, but how to avoid this and fix it? I'm new to this :-)
5d24c6cd7a0e7812931070.png

this.broilerDayService.fetch(this.breedId)
      .subscribe(broilerDays => {
        this.broilerDays = broilerDays
        broilerDays.slice(0).reverse().map(item => {
            console.log(this.broilerDays)
          item.startDayResidue = this.residue
          this.residue -= item.killingCount
          this.residue -= item.deathsCount
        })
      })

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question