Created
October 14, 2016 21:20
-
-
Save S0c5/488ff0aad7df8a5c241dab6169a54732 to your computer and use it in GitHub Desktop.
This file contains 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 convert(from, to){ | |
return fetch('https://www.google.com/finance/converter?a=1&from='+from+'&to='+to+'&meta=ei%3D0EUBWPCoAsermAG0oaiAAQ').then(res => res.text()).then(value => { | |
var doc = (new DOMParser()).parseFromString(value, "text/html");; | |
return +doc.querySelector('.bld').innerHTML.split(' ')[0] | |
}); | |
} | |
/** | |
usage : | |
convert('USD', 'COP') | |
.then(value => { | |
console.log(value); | |
}); | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment