When I upgraded my project to swift 2
with Alamofire 2
headers
stopped working without any errors in code. The reason is that he
You can fix the header problem
by sending headers
in requests
.
// login with Alamofire 2.0 and Swift 2.0 - WITH HEADER
func loginAlamofire_2(username:String) {
manager.request(.POST, "login_url", parameters: ["username" : username], encoding: ParameterEncoding.JSON, headers: ["Authorization": "yourToken"])
.response{ (request, response, data, error) -> Void in
if error != nil{
print("error!")
} else {
print("welcome")
}
}
}