Comcast/eel

How to use multiple "curl"s correctly ?

Closed this issue · 3 comments

I need to get several parts of a json document using a single curl request (that contains the whole document). Is it possible?

Yes, you can do this with a custom properties section in your eel handler - example:

"Transformation" : {
  "{{/comcast/quote}}" : "{{eval('/latestPrice','{{prop('comcast')}}')}}",
  "{{/comcast/symbol}}" : "{{eval('/symbol','{{prop('comcast')}}')}}"
},
"CustomProperties" : {
  "comcast":"{{eval('/quote','{{curl('GET', 'https://api.iextrading.com/1.0/stock/cmcsa/batch?types=quote,news,chart&range=1m&last=1')}}')}}"
}

Will there be 2 curl requests or 1 ?

There will be only one curl call, which is intentional. By placing it in the custom properties section of the handler you are sort of creating a local variable (called comcast here) to hold the results of the curl. In the transformation you can then refer to this local variable multiple times.