Skip to main content

Checking if Cover is Booked

The hasCoverBooked method checks whether a cover has been booked for a given bet ID. This is useful to determine if a particular bet has coverage.

Once these steps are completed, the user can proceed to following points for the insurance cover for the bet.

Usage

import kohin from "./kohinInstance";

const coverBookedResponse = await kohin.hasCoverBooked({
betId: 219,
betType: "Combo", // Type of bet: "Combo" for express bet, "Single" for ordinar bet
});

if (coverBookedResponse.success) {
console.log("Is Cover Booked:", coverBookedResponse.isBooked);
} else {
console.error(
"Error checking if cover is booked:",
coverBookedResponse.error
);
}

Return Value

The hasCoverBooked method returns an object with the following structure:

{
success: boolean; // Indicates if the operation was successful
error?: string; // Error message if the operation failed
isBooked?: boolean; // Boolean indicating if the cover is booked
}

Error Handling

Here's how you can handle errors while checking if the cover is booked:

try {
const res = await kohin.hasCoverBooked({ betId: 219, betType: "Combo" });

if (res.success) {
console.log("Is Cover Booked:", res.isBooked);
} else {
console.error("Error checking if cover is booked:", res.error);
}
} catch (error: any) {
console.error("Unexpected error while checking cover booking:", error);
}

Example Response

Success Response:

{
"success": true,
"isBooked": true
}

Error Response:

{
"success": false,
"error": "Unable to check if cover is booked."
}