Skip to content

Commit

Permalink
fix: check 404 before failing - otherwise new types will produce fail…
Browse files Browse the repository at this point in the history
…ures in development
  • Loading branch information
federicobadini committed Jan 11, 2024
1 parent 24db16d commit 096788a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ export class ContentFetcher<Content = any> {
const query = this.computeQuery(params);
const endpoint = `${this.endpoint}?${query}`;
const response = await fetch(endpoint);
if (!response.ok) {
throw new Error(`Failed to fetch from ${endpoint}`);
}
if (response.status === 404) {
throw new ContentTypeNotFoundError(this.apiId);
}
if (!response.ok) {
throw new Error(`Failed to fetch from ${endpoint}`);
}
return response.json();
}

Expand Down

0 comments on commit 096788a

Please sign in to comment.