1

On pages/tags.vue I am using this to fetch my api :

async fetch () {
        this.fetchresults = await this.$http.$get('https://api.domain/tags')
        this.tags = this.fetchresults.results;
  },

Its working fine but when I try to do the same thing from layouts/default.vue 90% of the time the tags is empty, its seem to only work once when I update my code then when I refresh tags is empty again. I cant use async fetch from the layout ?

Tahola
  • 1,040
  • 3
  • 19
  • 38
  • duplication of https://stackoverflow.com/questions/58205391/nuxtjs-use-asynddata-method-in-layout-or-component – Dvdgld May 20 '20 at 22:51
  • Thanks I saw that post but that really doesnt help, when I paste something on store/index.js I allways get a parse error. – Tahola May 21 '20 at 08:55
  • try to use getters in layout – Dvdgld May 21 '20 at 13:56
  • its ok I found the solution, I can use fetch() from components and its load fine if I do "fetchOnServer: false", its not SEO friendly but it work fine. – Tahola May 21 '20 at 17:19

0 Answers0