Skip to content

Files

Latest commit

 

History

History
45 lines (34 loc) · 820 Bytes

no-timing-in-fetch-data.md

File metadata and controls

45 lines (34 loc) · 820 Bytes

Pattern: Use of setTimeout/setInterval in asyncData/fetch

Issue: -

Description

This rule is for preventing using setTimeout/setInterval in asyncData/fetch since it may lead to memory leak.

Examples of incorrect code for this rule:

export default {
  asyncData() {
    let foo = 'bar'
    setTimeout(() => {
      foo = 'baz'
    }, 0)
  },
  fetch() {
    let foo = 'bar'
    setInterval(() => {
      foo = 'baz'
    }, 0)
  }
}

Examples of correct code for this rule:

export default {
  async asyncData() {
    let foo = 'baz'
  },
  fetch() {
    let foo = 'baz'
  }
}

Further Reading