Skip to content

Best way to handle error responses in Pinia Colada? #218

Closed Answered by posva
brandonleichty asked this question in Questions
Discussion options

You must be logged in to vote

There is intentionally no onError() hook in queries because you don't need them. Not only Vue already has watch for side effects like onError(), onSuccess, etc. But also, in practice, we don't want to have side effects in queries either, we want to keep our code declarative. We might want to have global query hooks, and that's a different story with the query hooks plugin. In mutations, side effects (like changing the cache) are much more common and they also allow us to delay the mutation (returning a promise in any of the hooks will make mutateAsynca resolve or reject after it).

Here is an example using the plugin mentioned above:

import { PiniaColada, PiniaColadaQueryHooksPlugin } from '…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hackel
Comment options

@posva
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants