async function showChapters(chapterURLs) { const chapterGenerator = function*() { for(const url of chapterURLs) { yield fetch(url).then(response => response.json()); } }; for (const chapter of chapterGenerator()) { try { appendChapter(await chapter)); } catch (error) { handleChapterErrorGracefully(error); } } }