Created
December 9, 2020 13:45
-
-
Save liflovs/04fb0453a0b37b88228ccf98a5f66510 to your computer and use it in GitHub Desktop.
Exchange rate Google App Sript example (EUR to UAH)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getEuroUahRate(date) { | |
var str = Utilities.formatDate(date,'GMT+3', 'yyyyMMdd') | |
var jsonArr = JSON.parse(UrlFetchApp.fetch('https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?date=' + str + '&json').getContentText()) | |
var json = null | |
for (var i = 0; i < jsonArr.length; ++i) { | |
if (jsonArr[i].cc == 'EUR') { | |
json = jsonArr[i] | |
} | |
} | |
if (json && json.rate) { | |
return json.rate | |
} else { | |
return null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment