HTTP Header Auth with Alamofire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func doMashape() -> Void { | |
let manager = Alamofire.Manager.sharedInstance | |
let headers = ["X-Mashape-Key": "MY_API_KEY", "Accept": "application/json"] | |
manager.request(.GET, "https://mashape-community-urban-dictionary.p.mashape.com/define?term=hipster", headers: headers) | |
.responseString { _, _, result in | |
if let receivedString = result.value { | |
print(receivedString) | |
} | |
} | |
} |
More options for headers with Swift 3.0/Alamofire 4.0: https://gist.github.com/cmoulton/ab674eb7bcb5aa1a0580fc8ba5176f6b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Alamofire ~> 3.0