Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 703 Bytes

File metadata and controls

22 lines (17 loc) · 703 Bytes

Copy paste this function in the Google script editor (corresponding to your active spreadsheet)

function convertFromEuro(currency) {
    // Make a GET request and log the returned content.
    var r = UrlFetchApp.fetch('http://api.fixer.io/latest');
    var data = JSON.parse(r.getContentText());
    //Logger.log(data.rates[currency]);
    return +data.rates[currency].toFixed(2);
}

💡 Use it in a cell spreadsheet

=convertFromEuro("RUB")

In a JavaScript vanilla style

const convertFromEuro = currency => fetch('https://api.fixer.io/latest').then(r => r.json()).then(r => console.log(r.rates[currency]));