SDK Errors
Handle WaitKitError thrown by the JavaScript SDK. Learn try-catch patterns, error status codes (400, 401, 404, 409, 429), and how to parse validation issues from API responses.
SDK methods throw WaitKitError when an API request fails. The error includes the HTTP status code and any validation issues.
WaitKitError
class WaitKitError extends Error {
name: "WaitKitError";
statusCode?: number;
issues?: Array<{ path: string; message: string }>;
}| Field | Type | Description |
|---|---|---|
message | string | Human-readable error message |
statusCode | number | undefined | HTTP status code from the API response |
issues | Array<{ path: string; message: string }> | Validation error details |
Handling errors
Check the error type before accessing SDK-specific fields:
import { WaitKit, WaitKitError } from "waitkit";
try {
await wk.subscribers.create({ email: "invalid" });
} catch (err) {
if (err instanceof WaitKitError) {
console.error(`Error ${err.statusCode}: ${err.message}`);
if (err.issues) {
for (const issue of err.issues) {
console.error(` ${issue.path}: ${issue.message}`);
}
}
} else {
// Network error or unexpected issue
console.error("Unexpected error:", err);
}
}Common error codes
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request | Missing or invalid email field |
| 401 | Unauthorized | Missing, invalid, or revoked API key |
| 404 | Not Found | Project slug does not exist |
| 409 | Conflict | Email already registered for this project |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Error | Server error (contact support if persistent) |
For detailed troubleshooting of each scenario, see the Troubleshooting guide.
TypeScript Types
Complete TypeScript type reference for the WaitKit SDK. Includes WaitKitConfig, JoinOptions, JoinResult, ApiResponse, WaitKitError, and all exported interfaces for type-safe integration.
REST API
WaitKit REST API reference. Base URL, Bearer token authentication, rate limiting, and available endpoints for collecting waitlist signups and querying subscriber counts.
