generated from tpl/purs
feat: Response.clone
This commit is contained in:
parent
00ec9cf08c
commit
d74d343165
@ -1,5 +1,8 @@
|
||||
/// <reference lib="dom" />
|
||||
|
||||
/** @type {(_: Response) => () => Response} */
|
||||
export const cloneImpl = rep => () => rep.clone()
|
||||
|
||||
/** @type {(_: Response) => () => Promise<unknown>} */
|
||||
export const jsonImpl = rep => () => rep.json()
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
module HTTP.Response
|
||||
( Response(..)
|
||||
, clone
|
||||
, json
|
||||
, text
|
||||
, blob
|
||||
@ -36,6 +37,7 @@ import Web.File.Blob (Blob)
|
||||
|
||||
foreign import data Response :: Type
|
||||
|
||||
foreign import cloneImpl :: Response -> Effect Response
|
||||
foreign import statusImpl :: Response -> Effect Int
|
||||
foreign import statusTextImpl :: Response -> Effect String
|
||||
foreign import headersImpl :: Response -> Effect (Object String)
|
||||
@ -54,6 +56,9 @@ guardStatusOk rep = do
|
||||
else
|
||||
pure unit
|
||||
|
||||
clone :: forall m. MonadEffect m => Response -> m Response
|
||||
clone = liftEffect <<< cloneImpl
|
||||
|
||||
json :: forall m @a. MonadAff m => ReadForeign a => Response -> m a
|
||||
json = liftAff <<< flip bind (liftEither <<< lmap (error <<< show) <<< runExcept <<< readImpl) <<< Promise.toAffE <<< jsonImpl
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user