tkh44 / holen

Declarative fetch for React
MIT License
150 stars 16 forks source link

Improved body PropType #18

Open jamesplease opened 6 years ago

jamesplease commented 6 years ago

The body could likely be limited to just strings and instanceof Blob, BufferSource, FormData, and URLSearchParams.

If you're :+1: I'll open a PR. Thanks!

Source

tkh44 commented 6 years ago

closed with https://github.com/tkh44/holen/pull/14

jamesplease commented 6 years ago

14 updated the response body prop called type; this issue is referencing the request body prop called body 🙂

I like the prop name body since it comes directly from the init object. I wonder if renaming type to be more explicit, like responseType, or responseBodyMethod would help people make sense of these two similar-but-different props. What do you think?

Also, I'm going to reopen this for now, but feel free to close if you're against restricting the body prop type.

My one hesitation with restricting it would be if fetch cast objects to strings, but a quick look suggests it might be strict in what it accepts as a body. I tried passing a RegExp in Chrome and it dropped it rather than stringifying it.