November 2019
Beginner
804 pages
20h 1m
English
The getNewBookDetails method will simply retrieve values for the different fields in the new book creation form (in a specific book collection) and will create a Book object corresponding to those values.
Let's add the code for it.
First, add the method and some defensive checks:
getNewBookDetails(collectionIdentifier: string): { error?: string, book?: Book } { if (!collectionIdentifier) {
// we throw this one because it means that there is a bug!
throw new Error("The collection identifier must be provided!");
}
// required
const newBookForm = document.getElementById(`newBook-$ {collectionIdentifier}`) as HTMLFormElement; if (!newBookForm) { throw new Error(`Could not find ...Read now
Unlock full access