How to display selected data from json object

When I run this function I have a JSON object as shown in the picture I just want to display only the selected option, say username.

 [displaying json object on running this function][1] 

$scope.signUp = function () {
    $http({
        method: "post",
        dataType:'json',
        url: "http://192.168.0.60/api/Customer/CustomerLoginService",
        crossDomain : true,
        data: {
            'username': $scope.username,
            'password': $scope.password,
             'entrytoken': $scope.entrytoken               
        },
     headers: { 'Accept':' text/plain','Content-Type': 'application/json' }
    }).then(function success(data) {
        alert("success function");
       var obj=JSON.stringify(data);
       alert(obj);                 
   });

      

enter image description here

how can i display the singe parameter.

+3


source to share


3 answers


then(function success(data) {        
       alert(data.data.username);
               });

      



+1


source


alert(obj.data.username);

      



Object properties can be accessed like a regular object. In the future, however, there is no need to format the return.

0


source


headers: { 'Accept':' text/plain','Content-Type': 'application/json' }
    }).then(function success(data) {
        alert("success function");
      // var obj=JSON.stringify(data);
       console.log('DATA=',data);

      

This will allow you to check if the username exists in the data response as a response. Open the browser panel to view the data. please use google chrome

0


source







All Articles