Fix commentary JSON parse error for chapters without coverage
This commit is contained in:
+2
-1
@@ -931,7 +931,8 @@ const App = () => {
|
|||||||
const cacheKey = `${commentaryId}/${bookAbbrev}/${chapterNumber}`;
|
const cacheKey = `${commentaryId}/${bookAbbrev}/${chapterNumber}`;
|
||||||
if (_commentaryCacheRef.current[cacheKey]) return _commentaryCacheRef.current[cacheKey];
|
if (_commentaryCacheRef.current[cacheKey]) return _commentaryCacheRef.current[cacheKey];
|
||||||
const res = await fetch(`https://bible.helloao.org/api/c/${commentaryId}/${bookAbbrev}/${chapterNumber}.json`);
|
const res = await fetch(`https://bible.helloao.org/api/c/${commentaryId}/${bookAbbrev}/${chapterNumber}.json`);
|
||||||
if (!res.ok) throw new Error(`No ${commentaryId} commentary for this chapter.`);
|
const contentType = res.headers.get('content-type') || '';
|
||||||
|
if (!res.ok || !contentType.includes('json')) throw new Error(`No ${commentaryId} commentary for this chapter.`);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
_commentaryCacheRef.current[cacheKey] = data;
|
_commentaryCacheRef.current[cacheKey] = data;
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
Reference in New Issue
Block a user