I'm working on some JavaScript code to convert an ID to a username with an API.
function id(numbers){
const Http = new XMLHttpRequest();
const url=`https://api.example.com/check.json?id=${numbers}`;
Http.open("GET", url);
Http.send();
Http.onreadystatechange = (e) => {
api = JSON.parse(Http.responseText)
document.getElementById(numbers).innerHTML = api.username
}
}
When I run the id() function the id I would like to convert as an argument, a request to the API should be sent with the ID in the query string. However, Javascript seems to be sending an incorrect ID. For example, I would run:
id(741152677165006859)
The code sends a request to api.example.com/check.json?id=741152677165006800. Why does Javascript trim the last two digits? This error doesn't happen when I pass the id to the function as a string.