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

Getting a list of Todo items

Our post call returns a list of items. Also, we can get items with this:

/// List todo items drop.get("todos") { request in     let todos = TodoStore.sharedInstance     let json: [Todo] = todos.listItems()     return try JSON(node: json) } 

We will build and run our application with Vapor CLI again and we can test this get request as follows:

curl -X "GET" "http://localhost:8080/todos" \   -H "Cookie: test=123"  

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