O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Posting a new Todo item

The first step will be to develop a post method to create a Todo item as follows:

/// Post a todo item drop.post("postTodo") { request in     guard let id = request.headers["id"]?.int,         let name = request.headers["name"],         let description = request.headers["description"],         let notes = request.headers["notes"],         let completed = request.headers["completed"],         let synced = request.headers["synced"]         else {             return try JSON(node: ["message": "Please include mandatory                 parameters"])     }     let todoItem = Todo(todoId: id,                        name: name,                        description: description,                        notes: notes,                        completed: completed.toBool()!,                        synced: synced.toBool()!)     let todos = TodoStore.sharedInstance     todos.addOrUpdateItem(item: todoItem)  let json: [Todo] = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required