fix: use node url

This commit is contained in:
orion 2023-11-18 17:42:22 -06:00
parent a5182dd45a
commit 42f55418fc
Signed by: orion
GPG Key ID: 6D4165AE4C928719
4 changed files with 5 additions and 16 deletions

View File

@ -10,6 +10,7 @@ package:
- maybe
- newtype
- node-buffer
- node-url
- prelude
- simple-json
- strings

View File

@ -4,7 +4,6 @@ import Prelude
import Control.Promise (Promise)
import Control.Promise as Promise
import Data.Newtype (unwrap)
import Data.Nullable (Nullable)
import Data.Nullable as Nullable
import Effect (Effect)
@ -15,8 +14,9 @@ import HTTP.Header (headers) as X
import HTTP.Request (class Request, Method(..)) as X
import HTTP.Request as Req
import HTTP.Response (Response)
import Node.URL (URL)
foreign import fetchImpl :: String -> String -> Object String -> Nullable Req.RawRequestBody -> Effect (Promise Response)
foreign import fetchImpl :: URL -> String -> Object String -> Nullable Req.RawRequestBody -> Effect (Promise Response)
fetch :: forall m a. MonadAff m => Req.Request a => a -> m Response
fetch req = do
@ -34,4 +34,4 @@ fetch req = do
Req.DELETE -> "DELETE"
headers' = Object.fromFoldableWithIndex headers
liftAff $ Promise.toAffE $ fetchImpl (unwrap url) methodStr headers' $ Nullable.toNullable body
liftAff $ Promise.toAffE $ fetchImpl url methodStr headers' $ Nullable.toNullable body

View File

@ -34,7 +34,7 @@ import HTTP.Header (ContentType(..), Headers(..))
import HTTP.Header as Header
import HTTP.MIME (MIME)
import HTTP.MIME as MIME
import HTTP.URL (URL)
import Node.URL (URL)
import Node.Buffer (Buffer)
import Node.Buffer as Buffer
import Node.Encoding (Encoding(..))

View File

@ -1,12 +0,0 @@
module HTTP.URL where
import Prelude
import Data.Newtype (class Newtype)
newtype URL = URL String
derive instance Newtype URL _
derive newtype instance Show URL
derive newtype instance Eq URL
derive newtype instance Ord URL