Adding a Shopping List

To add a Shopping List to our app is as simple making a POST request to the /shopping_lists endpoint with the JSON representation of our Shopping List Model that we want to create. We need to make this request to our Vapor API server and wait for a success response that contains the newly created shopping list object in JSON format. We will then convert it to a ShoppingList model and call the onCompletion handler function that is passed so that the ShoppingListTableViewController can add this new shopping list in its array of lists and tell the Table View to reload with this new Shopping List that is saved on the server.

To implement the add functionality that persists the new Shopping List in the database via our API, ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.