Last active
March 10, 2017 17:08
-
-
Save knaman2609/54d078b9655a30ae6951c3182eba75de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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