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

help: The setup binding property "$fetchState" is already declared. #74

Closed
amaury-tobias opened this issue May 22, 2020 · 3 comments
Closed
Assignees
Labels
question Further information is requested

Comments

@amaury-tobias
Copy link

📚 What are you trying to do? Please describe.
I using

const { $fetchState } = useFetch(async () => {
    articles.value = await app.$axios.$get('/articles')
 })
return { $fetchState }

and the console throw
"ERROR [Vue warn]: The setup binding property "$fetchState" is already declared."

🔍 What have you tried?
If I remove $fetchState from return the error don't appear but I can't use $fetchState on template

ℹ️ Additional context

@danielroe
Copy link
Member

danielroe commented May 22, 2020

@amaury-tobias

Yes, the $fetchState returned by useFetch is only for use in setup as there is already a $fetchState bound to the instance for use in the template.

When you say you can't use it in the template, what do you mean? (And just to confirm - you're using Nuxt 2.12+?)

@danielroe danielroe added the question Further information is requested label May 22, 2020
@amaury-tobias
Copy link
Author

Yes i use Nuxt 2.12.2, in template like

<p v-if="$fetchState.pending">Fetching posts...</p>
<p v-else-if="$fetchState.error">Error while fetching posts</p>
<p v-else> Loaded </p>

Now it's working, I think the browser cache caused it (I try to recreate the problem to report it, if appears).
So thank you for the information about $fetchState only can be used on the setup

@danielroe
Copy link
Member

Great - glad things are working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants