I'm trying to use alamofire to work with an api on a website. And so far, ive gotten it to give a response, but whenever I do, I keep getting a scope error.
Here is the code. I'm trying to get "response" out of there and into a variable
AF.request("\(website)/favorites.json", method: .get, headers: headers).responseString { response in
debugPrint("\(response)")
}
After the function, I tried putting print(response)
after the function so it looked like this:
AF.request("\(website)/favorites.json", method: .get, headers: headers).responseString { response in
debugPrint("\(response)")
}
print(response)
But I get this error:
error: MyPlayground.playground:30:7: error: cannot find 'response' in scope
print(response)
^~~~~~~~
How do I pass the response out of the function.