Nuxt asyncData Missing Data in Full Static Generate

Oct 5, 2020

When using asyncData and generate full static pages, I found some generated pages (npm run generate) have missing data loaded via asyncData.

  • This problem doesn't appear in development, only in npm run generate
  • The generated static pages should have embed the data loaded via asyncData in the html files, but somehow those data are missing.

The culprit is generate.routes in nuxt.config.js, when you have path which didn't start with /.

export default {  generate: {    routes: [      '/',      '/page/2',      'page/3' // this page will have missing data, as the path doesn't start with /    ]  }}

NOTE: Tested on Nuxt v2.14.6

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.