import { error } from '@sveltejs/kit';

export async function load({ fetch, params }) {
	const response = await fetch(`/api/books/${params.bookId}`);

	if (!response.ok) {
		error(response.status, 'This book could not be loaded.');
	}

	const book = await response.json();

	return { title: book.title };
}
