Created
March 9, 2017 11:03
-
-
Save knaman2609/ac265b2f60298598d1ad4e3b5d0e0e88 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 (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 Network.HTTP.StatusCode | |
import Data.Either (Either(..), either) | |
import Data.Maybe | |
api1 = do | |
e <- attempt $ Ajax.get "https://wwwogle.co.in/?q=" | |
case e of | |
Right resp -> pure (Just (Right resp.status)) | |
Left error -> pure (Nothing) | |
main = launchAff do | |
x <- api1 | |
case x of | |
Just (Right (StatusCode statusCode)) -> log $ "Right " <> (show statusCode) | |
Just (Left _) -> log "Left" | |
Nothing -> log "Left " | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment