DEV Community

Sanyam Jain
Sanyam Jain

Posted on

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

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()

Top comments (0)