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?
2
votes
1 Answers
2
votes
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.