RIP
Tutorial
Tags
Topics
Examples
eBooks
Tutorial by Examples
Making a Request
import Alamofire Alamofire.request(.GET, "https://httpbin.org/get")
Automatic Validation
Alamofire.request("https://httpbin.org/get").validate().responseJSON { response in switch response.result { case .success: print("Validation Successful") case .failure(let error): print(error) } }
Response Handling
Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) .responseJSON { response in print(response.request) // original URL request print(response.response) // URL response print(response.data) // server da...
Manual Validation
Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) .validate(statusCode: 200..<300) .validate(contentType: ["application/json"]) .response { response in print(response) }
Response Handler
Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]) .validate() .response { request, response, data, error in print(request) print(response) print(data) print(error) }
Chained Response Handlers
Alamofire.request(.GET, "https://httpbin.org/get") .validate() .responseString { response in print("Response String: \(response.result.value)") } .responseJSON { response in print("Response JSON: \(response.result.value)") ...
Page 1 of 1
1
Cookie
This website stores cookies on your computer.
We use cookies to enhance your experience on our website and deliver personalized content.
For more details on our cookie usage, please review our
Cookie Policy
and
Privacy Policy
Accept all Cookies
Leave this website