Reputation: 807
I want to send an http request to an external API using the Snap framework. Does Snap support it? If not, how to go about it?
Upvotes: 4
Views: 374
Reputation: 2967
Have you looked at using Network.Wreq
?
import qualified Data.ByteString.Lazy as LAZ
import qualified Data.ByteString.Lazy.Char8 as CHA
makeRequest :: IO (Network.Wreq.Response LAZ.ByteString)
makeRequest = do
res <- get "https://www.example.com"
let resBody = res ^. responseBody :: CHA.ByteString
return (resBody)
Uses simple lens syntax and supports HTTP and HTTPS.
Upvotes: 2