Loading...
Understanding error codes and responses from the CheapVHR API
{
"error": "Error Type",
"message": "Detailed error description",
"code": 400
}{
"error": "Invalid VIN format",
"message": "VIN must be 17 characters long",
"code": 400
}{
"error": "Missing required parameter",
"message": "VIN parameter is required",
"code": 400
}{
"error": "Unauthorized",
"message": "API key is required",
"code": 401
}{
"error": "Unauthorized",
"message": "Invalid API key",
"code": 401
}{
"error": "Not Found",
"message": "Report with ID 12345 not found",
"code": 404
}{
"error": "Not Found",
"message": "Endpoint not found",
"code": 404
}{
"error": "Too Many Requests",
"message": "Rate limit exceeded. Try again in 60 seconds",
"code": 429,
"retry_after": 60
}{
"error": "Internal Server Error",
"message": "An unexpected error occurred",
"code": 500
}try {
const response = await fetch('https://api.cheapvhr.com/v1/user/info', {
headers: {
'x-api-key': 'your-api-key'
}
});
if (!response.ok) {
const error = await response.json();
console.error(`Error ${error.code}: ${error.message}`);
return;
}
const data = await response.json();
// Handle success
} catch (error) {
console.error('Network error:', error);
}