Closed tkh44 closed 7 years ago
Yes!
What do you exactly have in mind?
@vesparny I think I want to add a responseTransformer
prop or something like that. The default would be:
(res) => res.json()
The only tricky part is I think we also need to pass in onError and onSuccess handlers to this transformer so that we can hook it into the existing success/error handling.
Maybe something like
(res, onSuccess, onError) => res.json().then(onSuccess).catch(onError)
What do you think?
I also wonder if it should be more generic so users can do more than just transform the request. Maybe the more generic version can live on a different prop.
At the moment unfetch
supports :
what about having an API like:
<Holen
body={JSON.stringify({ message: 'hello' })}
method="POST"
url="api.startup.com/users"
type="json"
transformResponse={(data) => {
data.isDecorated = true
return data
}}
>
{({data}) => <pre>{data.isDecorated}</pre>}
</Holen>
That looks great!
Will work on it tomorrow :)
cheers
closed in #3
Hi @tkh44. May I help on this one?