Im trying to pull total supply from bscscan but get the extra 9 decimal places on the response.
I’m trying to shorten with the code below. Please take a look and tell me what I’m missing.
Response I receive:
75590750847468907884
What I need:
75,590,750,847
Thank you!
const api_url = 'https://api.bscscan.com/api?module=stats&action=tokenCsupply&contractaddress=0x0025b42bfc22cbba6c02d23d4ec2abfcf6e014d4&apikey=1MPUYQ8DQ3KEJXXJVATPF8HH9ZT5MURQMS';
async function getSupply() {
const response = await fetch(api_url);
const data = await response.json();
const { result } = data;
var num = result;
var str = num.toString();
var value = str.substring(0,11)
value = parseInt(value);
document.getElementById('result').innerHTML = value;
}
getSupply();