Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Pauan/c8bc99fded34be4fc874ad50f7acdd73 to your computer and use it in GitHub Desktop.
Save Pauan/c8bc99fded34be4fc874ad50f7acdd73 to your computer and use it in GitHub Desktop.
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class
import Control.Monad.Aff (launchAff, Aff, makeAff, attempt)
import Control.Monad.Aff.Console (CONSOLE, log)
import Control.Monad.Eff.Exception (Error, try)
import Network.HTTP.Affjax as Ajax
import Data.Either (Either(..), either)
api1 = do
resp <- Ajax.get "/api1"
pure resp.response
api2 x = do
let url = "/api" <> x
resp <- Ajax.get url
pure resp.response
main = launchAff do
result <- attempt do
x <- api1
y <- api2 x
...
case result of
Right resp -> log resp
Left error -> log error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment