无法从Web服务中的后端获得预期的响应

时间:2018-10-23 06:24:43

标签: javascript angularjs

我在AngularJS中编写了一个api调用,以从后端JAVA获取数据

这是我的代码

$scope.memberForm = {}; 
$scope.memberForm.member_address = {}; 
$scope.memberRegForm = function() {
    $scope.btnloading = true;
    $('#add-btn').prop('disabled', true);
    url = '/member/add';
    var request = $http({
        method: "post",
        url: url,
        data: angular.toJson($scope.memberForm),
        headers: {
            'Content-Type': 'application/json'
        },
    });
}

但是我没有得到支持者的渴望响应,实际上是我从后端得到的响应是

{
    "fullname":"sdfgsdf",
    "fathername":"sdfsdf",
    "email":"sdfsdf@gmail.com",
    "date_of_birth":"1993-03-24",
    "admission_date":"2018-10-22",
    "phoneno":"0987654321",
    "nationality":"United States",
    "member_address":
    {
        "address":"5 meadow st",
        "state":"Connecticut",
        "zipcode":"06770",
        "district":"zc"
    },
    "college":"cvbcv",
    "qualification":"bcvbcv",
    "slno_ivpr":"12"
}

但这是我的欲望回应。我需要member_address作为对象数组而不是单个对象

{
    "fullname": "avinash",
    "fathername": "xxxxxxx",
    "date_of_birth": "1991-08-08",
    "nationality": "indian",
    "admission_date": "2015-08-08",
    "college": "ABC college",
    "slno_ivpr": null,
    "phoneno": "1234567890",
    "email": "avinash.mitresource@gmail.com",
    "remarks": "no remarks",
    "member_renewal": [],
    "qualification": "MCA",
    "member_address": [
        {
            "address": "piratlanka,repalle",
            "state": "AP",
            "district": "Guntur",
            "zipcode": "522264",
            "type": "PermanentAddress"
        },
        {
            "address": "padamata",
            "state": "AP",
            "district": "vijayawada",
            "zipcode": "522201",
            "type": "ResidencialAddress"
        }
    ]
}

0 个答案:

没有答案