1
votes

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
What is the error you are getting? The JSON doesn't print? - Mtoklitz113
Don't worry about it. Once I deployed my code to heroku, and used that url instead or localhost, everything worked fine. I think it is a problem with the iPhone simulator. - JacobSiegel

1 Answers

1
votes

For some reason it is an issue with the local host url. Works when code is deployed.