Skip to content

Instantly share code, notes, and snippets.

@knaman2609
Last active March 10, 2017 17:08
Show Gist options
  • Save knaman2609/54d078b9655a30ae6951c3182eba75de to your computer and use it in GitHub Desktop.
Save knaman2609/54d078b9655a30ae6951c3182eba75de to your computer and use it in GitHub Desktop.
module Main where
import Prelude
import Control.Monad.Eff.Class
import Network.HTTP.StatusCode
import Network.HTTP.Affjax as Ajax
import Control.Monad.Aff (Aff, Canceler(..), attempt, launchAff, makeAff)
import Control.Monad.Aff.Console (CONSOLE, log)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception ( Error, try)
import Data.Either (Either(..), either)
import Network.HTTP.Affjax (AJAX, get)
getDeviceDetails (Right x) = Right ("hello" <> x)
getDeviceDetails (Left _) = Left "Error"
api1 = do
e <- attempt $ (get "https://gitter.im/purescript/purescript" )
case e of
Right resp -> pure (Right resp.response)
Left error -> pure (Left "Error")
main = launchAff do
x <- api1
let y = getDeviceDetails x
case y 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