1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| export function getCryptoInfos(crypto) {
const url = 'https://api.coincap.io/v2/assets/' + crypto;
console.log("URL: " + url);
return fetch(url, {
method: 'get'
})
.then(reponse => reponse.json())
.catch(error => console.log('error', error));
}
function getTransactionFees() {
let unitPrice = 0
switch ($w('#tranfertRx').value) {
case "trc20":
getCryptoInfos("tron")
.then((cryptoInfo) => {
unitPrice = cryptoInfo.data.priceUsd
console.log("test unitPrice =" + unitPrice)
})
console.log("unitPrice =" + unitPrice)
return 1 * unitPrice
break;
case "bep20":
getCryptoInfos("binance")
.then((cryptoInfo) => {
unitPrice = cryptoInfo.data.priceUsd
})
console.log("unitPrice =" + unitPrice)
return 0.0005 * unitPrice
break;
case "erc20":
getCryptoInfos("ethereum")
.then((cryptoInfo) => {
unitPrice = cryptoInfo.data.priceUsd
})
console.log("unitPrice =" + unitPrice)
return 0.005 * unitPrice
break;
default:
return 0.00
}
} |
Partager