Support plugins/middlewares #875
-
I noticed most times I use SWR I need to wrap it to match the project needs or current stack. Some projects use HTTP status codes to describe the errors in the application layer, which would automatically throw when using That would require doing things like the following.
So I was thinking perhaps it is cleaner to support middlewares or observer logic with For global config.
Then If you wanted to append more
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@scucchiero thanks for providing your use case, we've had a ongoing RFC about plugins/middleware design, feel free to add any thoughts or releated feature requests there. for the usage you give above, do you feel the below approach could work? const {data, error} = useSWR()
const processedData = useMemo(() => {
return middleware(data) // or you can use any other ways to apply your middlewares
}, [data]) |
Beta Was this translation helpful? Give feedback.
-
Now #1160 has been merged, feel free to share you feedback! |
Beta Was this translation helpful? Give feedback.
@scucchiero thanks for providing your use case, we've had a ongoing RFC about plugins/middleware design, feel free to add any thoughts or releated feature requests there.
for the usage you give above, do you feel the below approach could work?