feat: add API key signup prompt to rate limit error messages if no api key is provided

This commit is contained in:
enesgules 2025-10-23 17:21:10 +03:00
parent 326c1e8763
commit d43a64bc24

View File

@ -51,7 +51,9 @@ export async function searchLibraries(
if (!response.ok) {
const errorCode = response.status;
if (errorCode === 429) {
const errorMessage = "Rate limited due to too many requests. Please try again later.";
const errorMessage = apiKey
? "Rate limited due to too many requests. Please try again later."
: "Rate limited due to too many requests. You can create a free API key at https://context7.com/dashboard for higher rate limits.";
console.error(errorMessage);
return {
results: [],
@ -116,7 +118,9 @@ export async function fetchLibraryDocumentation(
if (!response.ok) {
const errorCode = response.status;
if (errorCode === 429) {
const errorMessage = "Rate limited due to too many requests. Please try again later.";
const errorMessage = apiKey
? "Rate limited due to too many requests. Please try again later."
: "Rate limited due to too many requests. You can create a free API key at https://context7.com/dashboard for higher rate limits.";
console.error(errorMessage);
return errorMessage;
}