Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have a front-end app in Angular and back-end in Rails. I totally decoupled those two for sake of easy maintenance.

In my backend in Rails, I have a model called Document with three different params (User_id(integer), Data(json), Title(string)). In my front end, I have a variable called formData which is json data living in localStorage in Angular. I'm not sure whether I'm writing the code correctly to send formData as a parameter in HTTP request below.

Here is the request I have:

$http.post('http://localhost:3000/documents', { user: $scope.user, formData: $scope.formData }, function (response) {
                $scope.isSaved = true;
                console.log(response);
                if (response.success) {
                    console.log("It has been successfully saved!")
                }
            });

The origin I'm sending the request is http://localhost:3001/i129. From this website, I need to extract the document title where user is at (which is i129) and User_ID. How do I do that?

Am I send formData correctly above? Let's say

share|improve this question

For CRUD operations just like you want I'd recommend to use a higher level tool in the Angular frontend like the $resource service which is built on top of $http. On this link you have an explanation of how to use it and an entire example with movies that you can probably relate to your needs.

Basically, you configure the endpoint of your backend API and then you can use nice methods like get(), save() and delete() instead of http API calls.

Hope it helps!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.