-
Notifications
You must be signed in to change notification settings - Fork 77
Description
So, my actual use case is this:
I want to do client-side validation, and I have a general wrapper for useSWRV that passes back refs for data, error, etc. For some query parameters, I want to do client-side validation, and if it errors, I want to assign that to the error ref.
My first thought was: "Oh, maybe I can just throw an error in the key getter." However, that didn't work, as there's no error handling there. I thought maybe I could dynamically pass it to the fetcher function, but I don't see how without messing up hashing of the key. In other words: the query object is reactive, and will trigger a mutate automatically, so this validation has to happen "within" the useSWRV callback somehow.
IMO the easiest would be to allow errors to be thrown in the key getter, which then get assigned to error. Unless there's some other method you can think of?