问题
I built a REST API with node.js and express and I am storing my data with mongodb.
When I send different HTTP verbs to my localhost address (http://localhost:8080/) using the Postman application, everything works perfectly.
Although, when I use Alamofire, for some reason I cannot connect to my localhost address. Here is my swift code:
func alamofireTest() {
let url = "http://localhost:8080/"
Alamofire.request(.GET, url)
.responseJSON { response in
debugPrint(response)
if let JSON = response.result.value {
print(JSON)
}
}
EDIT: I am running my app from the iPhone simulator.
Any help/suggestions would be fantastic!
回答1:
For some reason it is an issue with the local host url. Works when code is deployed.
来源:https://stackoverflow.com/questions/38337206/alamofire-with-localhost-connection-problems