November 2018
Intermediate to advanced
404 pages
10h 16m
English
Add the getAllHandler(completion:) method to handle the request for retrieving all items in the database:
// retrieve all itemsfunc getAllHandler(completion: @escaping([JournalItem]?, RequestError?) -> Void) { JournalItem.findAll() { items, error in guard let items = items else { return completion(nil, error) } completion(items, nil) }}
In the closure for the findAll() method, the retrieved array optional items is unwrapped. If the items array is a valid object, a completion closure with unwrapped items will be invoked; otherwise, a completion closure with an error will be called.
Since you do not need to render Stencil web pages for API-based web functions, it is convenient to use the curl command-line tool or a web ...
Read now
Unlock full access