Static GitHub Issues

[1432] Question: difference between fetch and asyncData

prev: Auto open browser when run dev
next: Update Nuxt

Hi!

It is confusing when to use fetch and when asyncData

They both can:

  • access context (store, params)
  • both can be called from the server-side

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?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1274">#c1274</a>)</em></sub></div>