Tanstack (vue) query throws error regardless of the throwOnError property
I've been trying to set up my Vue Query mutations so that errors are handled within the onError callback. However, instead of being caught there, the errors propagate to the root of my application, causing the Nuxt framework to display its error page. How to fix that?


3 Replies
extended-salmonOP•7mo ago
adding images of my vue query config and example of mutation
extended-salmonOP•7mo ago
if i call this function without try/catch block it throws Nuxt error causing application to crash which I don't want, I want to trigger onError callback which shows toast message based on the HTTP error code
if i call this function with the try/catch it works as expected but I don't want to wrap each mutation within the try catch block

correct-apricot•7mo ago
mutateAsync
throws by default, cause you are awaiting promise. It has to either resolve or reject, and we should not swallow the error in that case.
I believe you want to use mutate
which should respect throwOnError
.