April 2017
Intermediate to advanced
316 pages
9h 33m
English
To retrieve all Todo items, unlike our post call, we do not need to pass any header parameters, just cookie information. So, we add the following struct to handle this scenario:
struct RequestModel: RequestProtocol { subscript(key: String) -> (String?, String?) { get { switch key { default: return ("Cookie","test=123") } } } }
Then, we can retrieve a list of Todo items using the following code:
sendRequest(Urls.getTodos, request: RequestModel()) { (response, error) in if error == nil { let todos: [Todo]? = decode(response!) completion(todos, nil) print("request was successfull: \(todos)") } else { completion(nil, error) print("Error: \(error?.localizedDescription)") } }
Although we added better error ...
Read now
Unlock full access