async componentDidMount()

in assets/src/modules/search/SearchGallery.tsx [26:53]


  async componentDidMount() {
    try {
      const searchResults = await this.searchBooks();

      // Map the search results to a book object
      const books = [];
      for (var i = 0; i < searchResults.hits.total; i++) {
        var hit = searchResults.hits.hits[i] && searchResults.hits.hits[i]._source;
        hit && books.push({
          author: hit.author.S,
          category: hit.category.S,
          cover: hit.cover.S,
          id: hit.id.S,
          name: hit.name.S,
          price: hit.price.N,
          rating: hit.rating.N,
        });
      }

      this.setState({ 
        books: books
      });
    } catch (e) {
      alert(e);
    }

    this.setState({ isLoading: false });
  }