SWR useRequest function using Axios with hard to use mutate
function
#695
Unanswered
hoetmaaiers
asked this question in
Q&A
Replies: 2 comments 1 reply
-
I'm running into the same issue. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Sorry, I replace SWR in favor of React-Query.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When trying to combine SWR with Axios, I like the approach I found in the examples: https://github.com/vercel/swr/blob/master/examples/axios-typescript/libs/useRequest.ts
This way my axios config resembles the keyInterface, this is great.
The problem starts when I try to mutate my data. In the bound mutate function, the expected data includes the whole AxiosResponse object, which makes no sense when locally mutating.
Am I doing something wrong with the demo? Or am I misusing the mutate functionality?
Demo:
I use the basic
useRequest
hook from the examples (link above). When I act on the mutate function returned fromuseRequest()
like this:mutate({ data: updatedAnswers}, false);
, I receive this compiler error:Beta Was this translation helpful? Give feedback.
All reactions