Closed Suro4ek closed 1 year ago
for example, I make a request, but I don't get an error from 500 codes
return fetch(url, {
method: 'POST',
body: JSON.stringify(data)
}).then(res => res.json())
@Suro4ek Hey there! 👋
First, here's a repro of the mutation that catches errors. Try clicking on +5 or -5 buttons, you'll see that in 20% of cases it reverts the changes to the cache and shows an error. So if something doesn't return errors to you, can you please provide a repro on stackblitz?
Second is this:
but is it possible to make a request to the mutate as in swr there in mutate useSWR('/api/user', fetcher)?
I'm not sure what you're talking about here 🤔 If you're talking about bound mutator, then yes, we have it. But we typically advice to use mutation stores (useSWRMutation
in SWR terms). Again, feel free to expand on your thoughts in code/stackblitz/whatever.
I'll close it for now, feel free to reopen if something's missing/unclear.
as I understand it, I should just return fetch inside createMutatorStore, but is it possible to make a request to the mutate as in swr there in mutate useSWR('/api/user', fetcher)?