@@ -29,16 +29,16 @@ postForms
29 :: ( IsBlob blob, HasJSContext (Performable m), MonadJSM (Performable m)
29 :: ( IsBlob blob, HasJSContext (Performable m), MonadJSM (Performable m)
30 , PerformEvent t m, TriggerEvent t m
30 , PerformEvent t m, TriggerEvent t m
31 , Traversable f)
31 , Traversable f)
32− => Text
32+ => Text -- ^ The target url
33− -> Event t (f (Map Text (FormValue blob)))
33+ -> Event t (f (Map Text (FormValue blob))) -- ^ Maps of text keys and values that will be sent as "FormData"
34 -> m (Event t (f XhrResponse))
34 -> m (Event t (f XhrResponse))
35−postForms path payload = do
35+postForms url payload = do
36 performMkRequestsAsync $ ffor payload $ \fs -> for fs $ \u -> liftJSM $ do
36 performMkRequestsAsync $ ffor payload $ \fs -> for fs $ \u -> liftJSM $ do
37 fd <- FD.newFormData Nothing
37 fd <- FD.newFormData Nothing
38 iforM_ u $ \k v -> case v of
38 iforM_ u $ \k v -> case v of
39 FormValue_Text t -> FD.append fd k t
39 FormValue_Text t -> FD.append fd k t
40 FormValue_File b fn -> FD.appendBlob fd k b fn
40 FormValue_File b fn -> FD.appendBlob fd k b fn
41− return $ xhrRequest "POST" path $ def & xhrRequestConfig_sendData .~ fd
41+ return $ xhrRequest "POST" url $ def & xhrRequestConfig_sendData .~ fd
43-- | Converts a File (e.g., the output of a 'FileInput') into a 'FormValue'. The filename will be included if it is available.
43-- | Converts a File (e.g., the output of a 'FileInput') into a 'FormValue'. The filename will be included if it is available.
44fileToFormValue :: MonadJSM m => File -> m (FormValue File)
44fileToFormValue :: MonadJSM m => File -> m (FormValue File)