DEV Community

loading...

Understanding use of fetch, created, mounted in context of Nuxt

Sanyam Jain
Indie Developer from India
・1 min read

Context: nuxt generate

  1. On initial page load, fetch() will be called once. created() will be called twice(once on server, once on page load)

  2. fetch() is used only to get static data
    Before using fetch(), identify which piece of data is static(changes rarely) & which is dynamic(will change frequently).
    For example, in the case of a blog, title, blog content are static & comments are dynamic.

  3. fetch has access to both store & data()

Discussion (0)