import { Book } from './Book';

async function getBooks(): Promise<Book[]> {
  const response = await fetch('http://localhost:3001/books');
  return response.json();
}

const BooksList: React.FC = async () => {
  'use cache';

  const books = await getBooks();

  return (
    <section>
      <h2>Verfügbare Bücher:</h2>
      <ul>
        {books.map((book: any) => (
          <li key={book.id}>{book.title}</li>
        ))}
      </ul>
    </section>
  );
};

export default BooksList;
