'use cache';
import { Book } from '@/books/Book';
import { NextPage } from 'next';

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

const BooksPage: NextPage = async () => {
  const books = await getBooks();

  return (
    <div>
      <h1>Bücher</h1>
      <ul>
        {books.map((book) => (
          <li key={book.id}>{book.title}</li>
        ))}
      </ul>
    </div>
  );
};

export default BooksPage;
