Skip to content

Instantly share code, notes, and snippets.

@SyNeto
Created November 15, 2017 02:03
Show Gist options
  • Save SyNeto/0c788eee57fe4c745c91fe23b1303bdf to your computer and use it in GitHub Desktop.
Save SyNeto/0c788eee57fe4c745c91fe23b1303bdf to your computer and use it in GitHub Desktop.
fetch('https://min-api.cryptocompare.com/data/price?fsym=MXN&tsyms=BTC')
.then(response => {
if(response.ok){
return Promise.resolve(response);
} else{
return Promise.reject(new Error("No funciona"));
}
})
.then(response => response.json())
.then(data => {
var valor = convertir(data.BTC, cantidad);
desplegar(valor);
})
.catch(error => { console.log(`Error: ${error}`) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment