November 2018
Intermediate to advanced
404 pages
10h 16m
English
To create a new item, call the save() method to save the JournalItem object to the database:
func createItemHandler(item: JournalItem, completion: @escaping(JournalItem?, RequestError?) -> Void) { item.save(completion)}
Similar to the updateItemHandler(item, completion) method, createItemHandler(item, completion) expects a new JournalItem object submitted by user.
Check the createItemHandler(item:completion:) function with the following curl command:
$ curl --header "Content-Type: application/json" \--request POST \--data '{"title":"New Entry","content":"This is a brand new entry."}' \http://localhost:8080/api/admin
After posting the request to create a new journal entry, check all of your records in the database again: ...
Read now
Unlock full access