disallow
setTimeout/setInterval
inasyncData/fetch
- ⚙️ This rule is included in
"plugin:nuxt/recommended"
.
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'
}
}