跳转到内容

Check order status

此内容尚不支持你的语言。

Example of loop to monitor order status until completion:
Section titled “Example of loop to monitor order status until completion:”
// How often to check, time in milliseconds
const interval = 5000; // 5s
const id = 4685314; // Order id
const endpoint = `https://api.tronenergy.market/order/info?id=${id}`;
async function getStatus() {
try {
const response = await fetch(endpoint);
const data = await response.json();
console.log("Order status:", data);
if (data?.status === "Completed") {
console.log("Order completed");
clearInterval(loop);
}
} catch(err) {
console.error("Error fetching order:", err.message);
}
}
getStatus();
const loop = setInterval(getStatus, interval);