const response = await fetch("https://api.humandesignapi.nl/v2/charts/simple", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
"HD-Geocode-Key": "YOUR_GEOCODE_KEY",
},
body: JSON.stringify({ birthdate: "1990-01-15", birthtime: "14:30", location: "Amsterdam" }),
});
const result = await response.json();
if (!result.success) {
switch (result.errorCode) {
case "CREDITS_EXHAUSTED":
// Prompt user to upgrade or wait for reset
break;
case "RATE_LIMIT_EXCEEDED":
// Wait and retry after Retry-After header
break;
case "API_KEY_INVALID":
// Re-authenticate
break;
default:
console.error(`API error: ${result.errorCode} — ${result.message}`);
}
}