Checking Launch Status
Status values
Status
Meaning
Action
Polling strategy
interface LaunchStatus {
status: "pending" | "success" | "failed" | "rate_limited";
processedAt: string | null;
}
async function pollLaunchStatus(
eventId: string,
token: string,
options: { intervalMs?: number; maxAttempts?: number } = {}
): Promise<LaunchStatus> {
const { intervalMs = 5000, maxAttempts = 60 } = options;
const url = `https://api-blowfish.neuko.ai/api/v1/tokens/launch/status/${eventId}`;
for (let attempt = 0; attempt < maxAttempts; attempt++) {
const response = await fetch(url, {
headers: { Authorization: `Bearer ${token}` },
});
if (response.status === 401) {
throw new Error("JWT expired -- re-authenticate and retry");
}
if (!response.ok) {
throw new Error(`Status check failed: ${response.status}`);
}
const data: LaunchStatus = await response.json();
if (data.status !== "pending") {
return data;
}
await new Promise((resolve) => setTimeout(resolve, intervalMs));
}
throw new Error(`Launch status still pending after ${maxAttempts} attempts`);
}Handling JWT expiry during polling
After success
After failure
After rate limiting
Last updated