Hacker News new | past | comments | ask | show | jobs | submit login

Here is a way with a Generator (the chapterGenerator). Only writing this because I've seen a lot of comments lamenting lack of "streams"

    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);
        }
      }
    }



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: