Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send an http request using snap-framework?

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?

like image 357
milad zahedi Avatar asked Sep 10 '25 17:09

milad zahedi


1 Answers

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.

like image 99
Babra Cunningham Avatar answered Sep 13 '25 13:09

Babra Cunningham