Static GitHub Issues

[422] cache async data

prev: Axios interceptors
next: Define global components

I want to request async dada in page:

As the doc say that, the sync request must be placed in data() for server rendered, so my code is :

export default {
    name: 'home',
    serverCacheKey () {
      return Math.floor(Date.now() / 10000)
    },
    data () {
      return axios.get('repo/latest').then(res => {
        return {
          latestRepos: res.data
        }
      })
    }
  }

but every time I open this page, I can find the ajax request is been sended to my server.

so the cache has no point?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c364">#c364</a>)</em></sub></div>