Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: useFetch's does not implement static target (payload is not saved) #127

Closed
gnuletik opened this issue Jun 19, 2020 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@gnuletik
Copy link

gnuletik commented Jun 19, 2020

πŸ› The bug
When using useFetch hook and generating a full-static build (target: static) and nuxt export, the useFetch payload is not saved.

πŸ› οΈ To reproduce

pages/test.vue

export default defineComponent({
  setup () {
    const name = ref('')

    useFetch(async () => {
      name.value = await axios.get('https://myapi.com/name')
    })
  }
})

nuxt.config.js

export default {
  target: 'static'
}

yarn run nuxt build && yarn run nuxt export && http-server dist && xdg-open localhost:8080

When I load index and navigate to the page test, I can see the network request in the Network tab of the browser.

🌈 Expected behaviour

The HTTP request should not be executed on client-side.

ℹ️ Additional context

I know there is useStatic but it does not allow to set a server target (if you want to make a second build which get data from client-side), does not support enablePreview, and other features implemented by nuxt static mode.
Also, useStatic requires code changes (which is specific to this package) instead of the useFetch implementation which has the same behavior as Nuxt's Options API.

Btw, thanks for this module :) It's awesome to combine the Composition API with Nuxt ! πŸŽ‰

@gnuletik gnuletik added the bug Something isn't working label Jun 19, 2020
@gnuletik gnuletik reopened this Jun 24, 2020
@danielroe
Copy link
Member

@gnuletik Thanks for the positive feedback 😊

I've just released 0.10.0 with support for full static in useFetch. Let me know if it works for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants