Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggested approach for PUT/PATCH/POST #6

Closed
stevewillard opened this issue May 24, 2019 · 4 comments
Closed

Suggested approach for PUT/PATCH/POST #6

stevewillard opened this issue May 24, 2019 · 4 comments

Comments

@stevewillard
Copy link

This package is great - thank you!

Do you have a suggested approach for mutations? Maybe something like usePost or usePut, which might return a function/promise.

@simoneb
Copy link
Owner

simoneb commented May 24, 2019

Thanks! Haven't thought much about this, but I think an API I would like, rather than introducing new root level exports, is something like this:

const [{ data, loading, error }, triggerRequest] = useAxios(
    'https://jsonplaceholder.typicode.com/todos/1',
    { skip: true }
  )

....

triggerRequest({ arguments to be merged with the original request configuration })

So the existing API would be unchanged, but we could pass options as a second argument, for instance with a skip (or maybe manual) properties to indicate that the request is not triggered right away but only when the second item of the array of the return value is invoked.

What do you think?

@stevewillard
Copy link
Author

stevewillard commented May 24, 2019

I definitely like the merging of options - I was thinking the same thing!

Not loving the { skip } option, (the name) manual is a bit better, but I like the general idea of what you're saying.

@simoneb
Copy link
Owner

simoneb commented May 25, 2019

Version 1.1.0 addresses this now. More details in the updated docs.

@stevewillard
Copy link
Author

Thank you! It looks great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants