Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 337: | Line 337: | ||
<source lang="javascript" line> | <source lang="javascript" line> | ||
result = http().get("http://api.fixer.io/latest?base=USD") // Use service http://fixer.io/ to get conversion rate in JSON format | result = http().get("http://api.fixer.io/latest?base=USD") // Use service http://fixer.io/ | ||
usdToEur = JSON.parse(result.body)["rates"]["Eur"] // Use standard JavaScript object JSON to parse the result | // to get conversion rate in JSON format | ||
entry().set("PriceEUR" , entry().field( "PriceUSD") * usdToEur ) // Multiply PriceUSD by the conversion rate to determine the value for PriceEUR | usdToEur = JSON.parse(result.body)["rates"]["Eur"] // Use standard JavaScript object JSON | ||
// to parse the result | |||
entry().set("PriceEUR" , entry().field( "PriceUSD") * usdToEur ) // Multiply PriceUSD by the conversion rate | |||
// to determine the value for PriceEUR | |||
</source> | </source> | ||