Wait/Poll for the Swap
Wait for SafeSwap to set up the destination chain Swap
Example
let swapInfo = null;
const intervalId = setInterval(() => {
const apiResponse = await fetch(`${SWAP_API_URL}/swaps?swapId=${swapId}`, {
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'MY_API_KEY'
}
});
const result = await apiResponse.json();
swapInfo = result[0];
if (swapInfo.targetContractId) {
console.log("the swap is ready");
clearInterval(intervalId);
} else {
console.log("Still waiting for the swap to be set up");
}
}, 3000);
Errors
Last updated