Guillermo López
Guillermo López

Reputation: 414

New fetch not working for components in nuxtjs

I'm having troubles with the new fetch method and full static in v2.13.X.

It works fine in page components, but I can't make it work in components using the new component module. It simply won't fire... I read all the documentations to see if I was wrong assuming it would work in full static or with the new components module, but I couldn't find anything close to what's going on with my code. Actually, I tried with Universal mode and it didn't work either.

I'm doing the following:

./components/test.vue

<template>
  <div>test</div>
</template>

<script>
export default {
  fetch() {
    console.log(`test me`)
  }
}
</script>

If I use this component in any page, it won't print anything in the console, if I copy and paste the fetch() method as it is in any page component, it'll print the message.

Anybody knows why it won't work in components loaded through the new component module in Nuxt?

Upvotes: 0

Views: 1698

Answers (1)

Guillermo L&#243;pez
Guillermo L&#243;pez

Reputation: 414

Apparently I forgot that I installed Nuxt globally when I was first testing it out. That's why the new "fetch" method didn't work, because the global version was still way back in v2.8.X

Simply npm i -g nuxt

Found in: https://github.com/nuxt/content/issues/97#issuecomment-639106282

Upvotes: 1

Related Questions