cI'm trying to, with Swift 2 and Alamofire, make a request to an API, and then store the data so that I can use it in another function.
For example, this is my code below, and I'm trying to figure out how to assign it to a variable so that I can use it later in the file. I've tried Google'ing and trying a bunch of options and I haven't got anywhere in the past 3 hours.
func getToken() {
Alamofire.request(.GET, "https://somesite.com/ping").responseJSON { response in
print(response)
}
}
So as we can see, we have the response, but could we assign the contents of it to a variable so we can use it in a function such as pryResponse
?
func pryResponse() {
print(response)
}
Something similar to that, but an actual variable.