contiamo / restful-react

A consistent, declarative way of interacting with RESTful backends, featuring code-generation from Swagger and OpenAPI specs 🔥
MIT License
1.87k stars 109 forks source link

Handle body object for DELETE request #291

Closed ApacheEx closed 4 years ago

ApacheEx commented 4 years ago

Why

Resolves #288

This is fully backward compatible for body of type string/number. So, this PR adds supports for body as FormData or Object which is useful for some cases.

Nice, that it's already like this in Mutate component. Only the hook has missed this point.

p.s somehow we need to avoid duplicating code/tests in the component and hook (If you have the same feeling, let me know, I will open a new issue to discuss in more details). Probably, I don't fully understand the idea of having two sources of truth (Component and Hook) instead of one (Hook).

So, my idea is to use hook in the component directly. So, all logic will be in one place (Hook). Just an example:

function Mutate({ children, ...mutateProps }) {
  const { mutate, loading, error, absolutePath } = useMutate(mutateProps);

  return children(mutate, { loading, error }, { absolutePath });
}

export default Mutate;

thoughts? 🤔

netlify[bot] commented 4 years ago

Deploy request for restful-react accepted.

Accepted with commit 8496aa9581b49bca536cb49cd77115282188f20d

https://app.netlify.com/sites/restful-react/deploys/5f31c81185def70007cfad71