0

I am new user in angurlar js or ionic i want to create the new web service When i send the data api in post method the result will not show or no sucess response. Here is my code.

$scope.registerNow = function() {
    var Urlss = "http://test.airspott.com/api/Customers";
    var email = $scope.register.email;
    var password = $scope.register.password;
    var datas ={"email":email,"password":password};

    alert(email);
    alert(password);
    alert(datas);

    $http.post(Urlss,datas)
        .success(function(data, status, headers, config) {
            var response = data;
            alert(response + "sucessfully added");
        });
    };
}

Please help me.

2 Answers 2

1

Maybe, you should stringify your datas object using JSON.stringify(datas):

var request = JSON.stringify(datas);
$http.post(url, request).succ...
0

If you want the response when you do the above stuff you need to have to return the Response object with the content you wanted to send to the client

POST request to ---> http://test.airspott.com/api/Customers with some data SO please try testing the response using POSTMAN or ADVANCE REST CLIENT in the browser first

If you get the response then you can try with the above angular client side code to expect a response and then do the stuff what ever you want

The Paradigm usually goes as following

Client[HTML+client side scripting language] from the Browser through UI | ^ | Request | | |Response V | Server Side Web services Code[JAX RS {JERSEY}] deployed as war(say) in tomcat

So what im trying to tell you is just try the response handling using the tool like Postman where you can execute all types of Requests

If you need more information on this please ask me

Thank you

Your Answer

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

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