FrontendDeveloper.in

Vue.js question detail

Is recommended to use async for computed properties?

No, it is not recommended. Computed properties should be synchronous. But if you still use asynchronous actions inside them, they may not work as expected and can lead to an unexpected behaviour.

For example, the below usage of async/await is not recommended,

async someComputedProperty () {
return await someFunction()
},

Note: If you still prefer to use async computed properties for some reason then you can consider using additional plugin such as vue-async-computed.

Back to all Vue.js questions
Get LinkedIn Premium at Rs 399