2
I am making a conversion from Chinese Currency (Yuan) to Brazilian Currency (Real). I am using the website API: https://free.currencyconverterapi.com
. Turns out I can’t set the value to be converted, the conversion only returns the result of a value conversion 1
. As if converting 1 to currency Real
. But in my code I want to convert 200 to currency Real
. Code:
$(document).ready(function(){
$('#resultado').html('Convertendo...');
var moeda = { CNY_BRL: 200 };
$.ajax({
url: 'https://free.currencyconverterapi.com/api/v6/convert?q=CNY_BRL&compact=ultra&apiKey=873041c527593ec7e31e',
dataType: 'jsonp',
success: function(data) {
moeda = data.CNY_BRL;
console.log(moeda);
$( "#resultado" ).html(moeda);
}
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
O valor convertido é: <span id="resultado"></span>