tristanhimmelman / AlamofireObjectMapper

An Alamofire extension which converts JSON response data into swift objects using ObjectMapper
MIT License
2.66k stars 475 forks source link

how i send headers with alamofire and use alamofireobjectmapper #207

Open oshitub123 opened 7 years ago

oshitub123 commented 7 years ago

this is my code let headers: HTTPHeaders = [ "Authorization": "Bearer " + "BQB8rIWF7Lk267E7o7pKNPhFvK4F6WoY16nKddTj4BdGLw5IF5hQM8Xk2ZlJFH0xJM7MR8fgqIdfSFmGMe9VVvmSWEg3mb1XGGvvntwV0VFyJBEQfmgH0XQ32VVIcFt__0xeTqzxs0J" ]

    Alamofire.request(url, headers:headers).validate().responseJSON() { response in
        switch response.result {
        case .success:
            if let result = response.result.value {
               let json = result as! NSDictionary
               let nam = json["display_name"] as? NSObject
               self.muestra.text = nam! as! String
               print(response)
            }
        case .failure(let error):
            print("Error in getTripDestination: \(error) \n no funciona correctamente l aplicacion intenta mas tarde")

            break
        }
Noodlekim commented 7 years ago

Yes, I want to solve this issue, too. I have a same issue.😢

oshitub123 commented 7 years ago

I got it man send me a message please

manu-lopez commented 7 years ago

I used this code and it works fine.

Alamofire.request(url, headers: header).responseObject { (response: DataResponse<Dog>) in

you have to import Alamofire and AlamofireObjectMapper

The rest is as in the examples