v2.2.0
π New features
Thanks to @jbaubree for suggesting implementing event hooks, which is a little nicer than using a watcher for detecting when a query concludes or fails.
onSuccess
This is called whenever a new result is available.
<script setup>
import { useQuery } from 'villus';
const { data } = useQuery({
query: GetPostById,
variables,
onSuccess: (data) => {
console.log(data)
},
});
</script>
onError
It is triggered when an error occurs.
<script setup>
import { useQuery } from 'villus';
const { data } = useQuery({
query: GetPostById,
variables,
onError: (err) => {
console.log(err)
},
});
</script>