Closed azmtbr closed 8 years ago
Hi Jon. You can't have two services run on the same port: you want to run your angular app on the usual port, and your Rails app on port 4000 for example (by running rails s -p 4000
).
Then you want to configure your ngResource to go to http://127.0.0.1:4000/api
and not simply /api
.
You also seem to have a typo (ngResourcs
instead of ngResource
).
You might also consider using restangular instead of the built-in ngResource
. Restangular
makes a few assumptions and ends up being more high-level.
Lastly, when you search the web or look for documentation, the fact that you're using Rails shouldn't matter. Just look for "how to consume API" or "consuming REST API from angular", etc…
@matstc -Ok, Restangular is working and they are finally talking to each other. That was a good end to my day! commit
-The only thing that I'm having issues with is getting the correct animal to show in the profile.
$scope.animal = Restangular.one('rescues/1/animals/', 4).get().$object;
-Right now I'm hardcoding the animals' id into this ^. I've tried a bunch of other things but to no success.
When this is finished, I think I'll start on the smaller "contact form" rather than the adoption form. This way I can get the Sendgrid functionality working and then just duplicate everything for the "adoption form." What do you think about this plan?
Hi Jon. It looks like your API isn't set up for CORS requests. You can tell from the error in the browser console whenever you make a request. I'll send you a PR to fix this.
And I think starting with the simpler form is a good idea.
PS: Could you make me a collaborator on your rescuesite-api repo?
@matstc -I'm still trying to get the data from the rails api to the frontend app. I want to say that I'm getting close but think that I'm missing something.
-Most of the things I've been researching are from people using angular from within the rails app so my problems of getting them to run on the same local server don't come up in what I'm seeing so far. I got them both to run on port 4000, but I can't really be sure that they're both on it at the same time because I cant see the data yet.
Here's the related commit: commit