i want to do: I am using this code in different areas and some token addresses show "Failed to load resource: the server responded with a status of 422 ()" error in the development console. if it can't get data from that token address, let it detect it and prevent it from showing an error
javascript
checkPrice();
function checkPrice() {
$.ajax({
url: "https://api.dex.guru/v1/tokens/0x3993453b9587e06a0e925727fd844d2d2babd39f-bsc/",
dataType: "json",
timeout: 30000,
success: function(data) {
$("#price").html("$" + data.priceUSD.toFixed(8));
checkPrice();
}
});
}
html
<div class="col text-end">
<span id="price">-</span>
</div>