RANDOM.ORG reference
Created
March 26, 2017 22:39
-
-
Save dgendill/548c083555c9da4fca8fd23a5071d42a to your computer and use it in GitHub Desktop.
Getting truely random numbers from RANDOM.org in PureScript
This file contains hidden or 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 | |
-- bower install | |
-- "purescript-prelude": "^2.5.0" | |
-- "purescript-console": "^2.0.0" | |
-- "purescript-affjax": "^3.0.2" | |
import Prelude | |
import Control.Monad.Aff (launchAff) | |
import Control.Monad.Aff.Console (log) | |
import Data.Either (Either(..)) | |
import Data.HTTP.Method (Method(..)) | |
import Data.Maybe (Maybe(..)) | |
import Network.HTTP.Affjax (affjax, defaultRequest) | |
main = launchAff $ do | |
res <- affjax $ defaultRequest { | |
url = "https://api.random.org/json-rpc/1/invoke", | |
method = Left POST, | |
content = Just """ | |
{ | |
"jsonrpc": "2.0", | |
"method": "generateIntegers", | |
"params": { | |
"apiKey":"your-api-key-here", | |
"n":20, | |
"min":1, | |
"max":20 | |
}, | |
"id": 42 | |
} | |
""" | |
} | |
log res.response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment