Skip to content
Permalink
c42494f3de
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
24 lines (22 sloc) 559 Bytes
'use strict'
const request = require('request')
console.log(process.argv)
try {
if (process.argv.length < 3) {
throw 'missing parameter'
}
const symbol = process.argv[2].toUpperCase()
const apikey = 'YOUR KEY HERE'
const url = `http://fixer.io/latest?access_key=${apikey}symbols=${symbol}`
console.log(url)
request.get( url, (err, res, body) => {
if (err) {
throw 'could not complete request'
}
const json = JSON.parse(body)
const output = JSON.stringify(json.rates, null, 2)
console.log(output)
})
} catch(err) {
console.log(err)
}