Hi!
It is confusing when to use fetch and when asyncData
They both can:
If I understand correctly I should use fetch
when I want to fill the store and asyncData
when I want to set up component data.
But asyncData
can access store too. So why there are these two methods?
fetch for vuex, asyncData for page data?
Use asyncData
only when you need to return data for the current component.
Use fetch
when you want to work with the store.
@cretueusebiu answer is the one :)
When you need to fetch some data for the store especially for a specific page (like search results), use fetch
, otherwise, use asyncData
.
It's more for code readability :+1:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@cretueusebiu answer is the one :)
When you need to fetch some data for the store especially for a specific page (like search results), use
fetch
, otherwise, useasyncData
.It's more for code readability :+1: