7

I have these API calls which I need to do in my AngularJS controller.

Any example will be helpful.

app.post('/user/auth', users.auth);
app.get('/user/logout', helpers.isAuthenticated, users.logout);
5
  • What are the name of the helpers.isAuthenticated and users.logout parameters which the api is expecting? Commented Mar 11, 2017 at 0:35
  • Thanks for the help, you can find all the details here. Commented Mar 11, 2017 at 1:44
  • stackoverflow.com/questions/42728872/… Commented Mar 11, 2017 at 1:44
  • So, you post another question which is an "extended" version of this one? You could have edited this (There was no need to post another one). Commented Mar 11, 2017 at 1:53
  • I first put a full question but no one responded so i break it down to understand things one by one. Commented Mar 11, 2017 at 1:54

1 Answer 1

11

You just need to make use of the $http service like this:

angular.module('app', [])
   .controller('ctrlname', ['$http', function($http){

    //POST sample
    $http.post('/user/auth', users.auth).then(function(response){
         //handle your response here
    });

    //GET sample
    //substitute 'param1' and 'param2' for the proper name the API is expecting these parameters
    $http.get('/user/logout/?param1=' + helpers.isAuthenticated + '&param2=' + users.logout).then(function(response){
         //handle your response here
    });

   }]
);
Sign up to request clarification or add additional context in comments.

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.