diff --git a/src/Fetch.purs b/src/Fetch.purs index 6db9bd3..ad2ee7d 100644 --- a/src/Fetch.purs +++ b/src/Fetch.purs @@ -1,6 +1,5 @@ module Fetch ( fetch - , fetchBody , module Data.HTTP.Method , module Fetch.Core.RequestCache , module Fetch.Core.RequestCredentials @@ -35,7 +34,6 @@ import Prim.Row (class Union) import Promise.Aff as Promise.Aff -- | Implementation of `fetch`, see https://developer.mozilla.org/en-US/docs/Web/API/fetch --- | For usage with `String` bodies. For other body types, see `fetchBody` -- | -- | Usage: -- | ```purescript @@ -57,29 +55,14 @@ import Promise.Aff as Promise.Aff -- | foreignJsonValue <- json -- | ``` fetch - :: forall input output @thruIn thruOut headers - . Union input thruIn (HighlevelRequestOptions headers String) - => Union output thruOut CoreRequest.UnsafeRequestOptions - => ToCoreRequestOptions input output - => String - -> { | input } - -> Aff Response -fetch url r = do - request <- liftEffect $ new url $ Request.convert r - cResponse <- Promise.Aff.toAffE $ Core.fetch request - pure $ Response.convert cResponse - --- | Like `fetch`, but can accept arbitrary `RequestBody`s. -fetchBody :: forall input output @thruIn thruOut headers body - . ToRequestBody body - => Union input thruIn (HighlevelRequestOptions headers body) + . Union input thruIn (HighlevelRequestOptions headers body) => Union output thruOut CoreRequest.UnsafeRequestOptions => ToCoreRequestOptions input output => String -> { | input } -> Aff Response -fetchBody url r = do +fetch url r = do request <- liftEffect $ new url $ Request.convert r cResponse <- Promise.Aff.toAffE $ Core.fetch request pure $ Response.convert cResponse diff --git a/test/Test/FetchSpec.purs b/test/Test/FetchSpec.purs index 3d6cc32..f0a519d 100644 --- a/test/Test/FetchSpec.purs +++ b/test/Test/FetchSpec.purs @@ -4,7 +4,7 @@ import Prelude import Data.ArrayBuffer.Types (Uint8Array) import Data.Maybe (Maybe(..)) -import Fetch (Method(..), Referrer(..), RequestMode(..), fetch, fetchBody) +import Fetch (Method(..), Referrer(..), RequestMode(..), fetch) import Fetch as Fetch import Fetch.Core.Duplex (Duplex(..)) import Foreign (unsafeFromForeign) @@ -42,7 +42,7 @@ spec = it "should send a Post request with stream body" do - { status, json } <- fetchBody "https://httpbin.org/post" + { status, json } <- fetch "https://httpbin.org/post" { method: POST , mode: Cors , body: helloWorldStream