1

I'm currently working on a project with a Rails backend and I need some help with translating this curl command please. We're using devise to allow a user to sign in but I'm not sure how to implement this into a AngularJS $http request.

curl -v -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://localhost:3000/users -d

"{\"user\":{\"email\":\"[email protected]\",\"password\":\"password\"}}”

2 Answers 2

1
app.controller('LoginController', function($http){
    var user = {"user":{"email":"[email protected]","password":"password"}};

    $http.post('http://localhost:3000/users',user).then(function(result){
        // success. do something
    });
});

So, you pretty much want to make a post request. For that, inject $http service into your controller or service where you want to make the request and invoke post to url with your user data, where user data is a json object.

Sign up to request clarification or add additional context in comments.

Comments

1

I would suggest you read this: http://www.learnwithdaniel.com/2015/10/rails-angular-authentication/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.