kam kam - 1 year ago 46
reST (reStructuredText) Question

How to use these 2 rest services in AngularJS, also how to call requrest for jwt from spring backend

I am trying to consume rest services but don't know how to call web services in angularjs from spring backend, also want to know how to integrage json web based token which I have written in spring backend in angularjs.

Webservice 1 : Login for admin

URL: <>
Request type: POST
Header type: Content-Type application/json
Parameters: {

Webservice 1 : Login for user

URL: <>
Request type: POST
Header type: Content-Type application/json
Parameters: {

My Code is:

authService.login = function(user, success, error) {
$http.post('misc/users.json').success(function(data) {
//this is my dummy technique, normally here the
//user is returned with his data from the db
var users = data.users;
var loginData = users[user.username];
//insert your custom login function here
if (user.username == loginData.username && user.password == loginData.username) {
//set the browser session, to avoid relogin on refresh
$window.sessionStorage["userInfo"] = JSON.stringify(loginData);

//delete password not to be seen clientside
delete loginData.password;

//update current user into the Session service or $rootScope.currentUser
//whatever you prefer
$rootScope.currentUser = loginData;

//fire event of successful login
//run success function
} else {
//unsuccessful login, fire login failed event for
//the according functions to run

Answer Source

You are using $http.post with a json file (Do not know where it comes from

You should replace it with the URL of your webservice + the data

     {"username" : "polo", "password" : dark99}).then(function(data){

    //Do what you want with the data returned from your webservice
}, function(error){
    //Handle error

NOTE : You only have 1 webservice which is located on