NMFES
NMFES

Reputation: 85

Refresh statically generated page (data) once it has loaded on client

For example I have some page in Nuxt:

data() {
        return {
            items: []
        };
    },
    asyncData() {
        return axios.get('site.com/url')
            .then((response) => {
                return {
                    items: response.data
                };
            });
    },

Then I run npm run generate and get statically generated html-page with data (items) from backend server. And when I open this page in browser I see that injected data into the page.

But these items might be updated on the backend so I need to see them once I have got refreshed the page with F5 and without running again npm run generate.

So looks like I should refetch data in mounted() section. Maybe Nuxt has something more suitable for this?

Upvotes: 0

Views: 280

Answers (1)

trenccan
trenccan

Reputation: 720

The only option is use crawler: false property in your nuxt.config.js file. It will disable static content generation from you dynamic pages. Here is the documentation.

Upvotes: 0

Related Questions