Nuxt.js: How does asyncData work with a static site?

Created on 19 May 2017  路  3Comments  路  Source: nuxt/nuxt.js

When I'm in development mode through npm run dev, asyncData always calls an API and updates my page with the latest information whether it is server-side rendered or client-side rendered. However, after I run npm run generate and deploy my site to S3, the page only displays the latest information when I navigate to the route from the client side. If I refresh the page to force a server render, asyncData does not update the page with new information. Is this by design? What would be the proper way to always force the API to be called from a static site? Should the API call also take place in a life cycle hook when it is server rendered?

This question is available on Nuxt.js community (#c632)

Most helpful comment

https://uptownhr.gitbooks.io/q-a-and-examples-for-nuxt-vue-js/content/chapter1.html

It will statically be set. So google and your users will see it all the time. If you want you're users to see an updated version, add another ajax call on the created hook

All 3 comments

To elaborate more on my use case, I do not care if Google sees old data, but I want the user to always see the latest data.

https://uptownhr.gitbooks.io/q-a-and-examples-for-nuxt-vue-js/content/chapter1.html

It will statically be set. So google and your users will see it all the time. If you want you're users to see an updated version, add another ajax call on the created hook

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surmon-china picture surmon-china  路  3Comments

vadimsg picture vadimsg  路  3Comments

maicong picture maicong  路  3Comments

uptownhr picture uptownhr  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments