I'm trying to get used to wreq
in Haskell with an exercice.
Basically, I'm calling a first API that returns me a list of ID, and then I would like to call the API that returns the object from the ID.
My code looks like this
getAllIds :: IO ()
getAllIds = do
r <-
asJSON =<< get "https://dummyUrl/objectA.json" :: IO A
let body = r ^. responseBody
print body
getOneItemFromId :: IO ()
getOneItemFromId = do
r <-
asJSON =<< get "https://dummyUrl/objectB/idOfObject.json" :: IO B
let body = r ^. responseBody
print body
How can I pass the result of getAllIds
into a call to getOneItemFromId recursively so that I can get a list of all the items based on the list of ID ?
This is a working example about printing a list comming from outside world one by one.
When executing the program above, It asks for input list and then print one by one
From here, you can modify your code to get it work. Below I provide a not-tested solution. (I can't install dependencies right now)