@@ -54,7 +54,6 @@ module Miso.FFI.Internal
54
54
, setBodyComponent
55
55
, addStyle
56
56
, addStyleSheet
57
- , fetchJSON
58
57
, shouldSync
59
58
) where
60
59
-----------------------------------------------------------------------------
@@ -408,53 +407,6 @@ addStyleSheet url = do
408
407
_ <- link # " setAttribute" $ [" href" , fromMisoString url]
409
408
void $ jsg " document" ! " head" # " appendChild" $ [link]
410
409
-----------------------------------------------------------------------------
411
- -- | Retrieve JSON via Fetch API
412
- --
413
- -- Basic GET of JSON using Fetch API, will be expanded upon.
414
- --
415
- -- See <https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API>
416
- --
417
- fetchJSON
418
- :: FromJSON action
419
- => MisoString
420
- -- ^ url
421
- -> MisoString
422
- -- ^ method
423
- -> Maybe MisoString
424
- -- ^ body
425
- -> [(MisoString ,MisoString )]
426
- -- ^ headers
427
- -> (action -> JSM () )
428
- -- ^ successful callback
429
- -> (MisoString -> JSM () )
430
- -- ^ errorful callback
431
- -> JSM ()
432
- fetchJSON url method maybeBody headers successful errorful = do
433
- successful_ <- toJSVal =<< do
434
- asyncCallback1 $ \ jval ->
435
- fromJSON <$> fromJSValUnchecked jval >>= \ case
436
- Error string ->
437
- error (" fetchJSON: " <> string <> " : decode failure" )
438
- Success result -> do
439
- successful result
440
- errorful_ <- toJSVal =<< do
441
- asyncCallback1 $ \ jval ->
442
- errorful =<< fromJSValUnchecked jval
443
- moduleMiso <- jsg " miso"
444
- url_ <- toJSVal url
445
- method_ <- toJSVal method
446
- body_ <- toJSVal maybeBody
447
- let jsonHeaders =
448
- [(ms " Content-Type" , ms " application/json" ) | isJust maybeBody]
449
- <>
450
- [(ms " Accept" , ms " application/json" )]
451
- Object headers_ <- do
452
- o <- create
453
- forM_ (headers <> jsonHeaders) $ \ (k,v) -> do
454
- set k v o
455
- pure o
456
- void $ moduleMiso # " fetchJSON" $ [url_, method_, body_, headers_, successful_, errorful_]
457
- -----------------------------------------------------------------------------
458
410
-- | shouldSync
459
411
--
460
412
-- Used to set whether or not the current VNode should enter the 'syncChildren'
0 commit comments