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

Body may need to be an opaque type #34

Open
justinwoo opened this issue Sep 19, 2019 · 8 comments
Open

Body may need to be an opaque type #34

justinwoo opened this issue Sep 19, 2019 · 8 comments

Comments

@justinwoo
Copy link
Owner

It might be necessarily to use an opaque type for body content in requests, for supporting things like formData.

@Cmdv
Copy link

Cmdv commented Jan 31, 2020

Ha I've just hit this issue when trying to do a GET with headers (for auth token) but get the error

Error: TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

I guess you could make:

type Options =
  ( method :: Method
  , body :: Maybe String -- make this a Maybe
  , headers :: Headers
  , credentials :: Credentials
  , follow :: Int
  , redirect :: Redirect
  )

But that would be quite the breaking change, also think this is related 😂

@justinwoo
Copy link
Owner Author

that's such a weird error, since it's noted in MDN and others that body is simply ignored

@Cmdv
Copy link

Cmdv commented Jan 31, 2020

yeah seems that window.fetch wants no body 😢
whatwg/fetch#551

This is a shame, I tried making body a Maybe locally, but when doing body: Nothing it still seems to add it!

what do you think would be a port of call for me to investigate? ps is this related to original issue ¯\_(ツ)_/¯

@justinwoo
Copy link
Owner Author

i'd just do the filtering here

return fetchImpl(url, options).catch(function(e) {
, seems like it's inevitable to do it at some level anyway

@Cmdv
Copy link

Cmdv commented Jan 31, 2020

cool got it working, want me to create a PR?

@justinwoo
Copy link
Owner Author

sure, sounds good

@i-am-the-slime
Copy link

I am just looking at sending formData with Milkis.
From reading this, I get the vibe that this isn't supported right now. I'd be fine to just unsafeCoerce if that's a workaround.
Do you think this would work?

@justinwoo
Copy link
Owner Author

yeah i use unsafeCoerce atm. if you want to prevent some accidental reusages you might wrap this function, but i haven't had any problems with coercing form data to this field.

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

No branches or pull requests

3 participants