Problem with Error: vue-query hooks can only be used inside setup() function.
I created custom composable to use on page login, but when hit that function i got that error. Is it my mistake or what.

7 Replies
rare-sapphireOP•2y ago
BTW, i use nuxt and vue query with this version
"nuxt": "^3.7.3",
"@tanstack/vue-query": "^4.35.3",
rare-sapphireOP•2y ago
this is composable file for useAuth

sensitive-blue•2y ago
Move
useAuth
call out of onSubmit
handler. In that handler you need to only call mutate
.rare-sapphireOP•2y ago
thanks man, it's work!!
next question, is it possible to watch "error" from function login @MrMentor
rare-sapphireOP•2y ago
like this

rare-sapphireOP•2y ago
i think
login
isn't reactive, because when i watch login.error
isn't triggered
is it my approach is wrong?sensitive-blue•2y ago
Login itself is not. But
error
prop is a ref, so it should be watchable.
I would suggest to pass onError
either to useMutation
or mutate
depending where and what you need to do.