Repository nuxt.js

When should i fetch server data .

yyyuuu777
0
yyyuuu777
commented a year ago

I get server data use asyncData or fetch method, but when i refresh my page, the data will lose, i feel fetch data by mounted callback is not awesome, but i don't know how to deal with this ?

    asyncData ({app}) {
      return app.$axios.$get(`/list`)
        .then((res) => {
          if (res.status === 200) {
            return { files_list: res.data.data }
          } else {
            console.error(res.msg)
          }
        })
        .catch((e) => {
          console.error(e)
        })
    },

any suggest very thanks .

0
pauldariye
74
pauldariye
commented a year ago

@yyyuuu777, perhaps using the vuex with persisted storage could help.

0
Informations
QuestionResolved
#c1711 - Created a year ago