NodeJS Request returning an empty array inside a J

2019-08-16 07:35发布

I am sending a POST JSON request to a URL and it is returning a JSON response. However, the array inside the JSON response is just returning [Object] instead of the Array of JSON elements it should be returning.

Why is this happening?

Ths is my code

var request = require('request');
var requestData = {
        "AERequest":{
            "serviceType":"BE",
            "deviceId": "Test",
            "accountId": "100008288964"
        }
};
const url = "https://ibluatapig.indusind.com/app/uat/balinq/AccountEnquiry?client_id=6867b781-9b21-45c5-9c55-948f7cd1a33f&client_secret=hP3yB3hM2oH4pH4hM1kV3uY8vR3qV7jY8cF6bG2sF5jX8lT1vN";
request({
    url: url,
    method: "POST",
    json: true,
    header: {
        "content-type": "application/json",
    },
    body: requestData
}, function(error, response,body){
    if(!error && response.statusCode === 200){
        console.log(body);l
    } else {
        console.log("error: "+ error);
        console.log("response.statusCode: "+ response.statusCode);
        console.log("response.statusText: "+ response.statusText);
    }
});

And this is the response:

{ AEResponse:
   { status: 'SUCCESS',
     accountID: '100008288964',
     SchmType: '',
     SchmCode: '',
     AcctCurr: 'INR',
     BankId: '',
     Name: '',
     BranchName: '',
     BranchId: '',
     City: '',
     StateProv: '',
     PostalCode: '',
     Country: '',
     AddrType: '',
     Addr1: '',
     Addr2: '',
     Addr3: '',
     AcctBal:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ] } }

Instead of these object elements, there should have been one array of small JSON objects of 2 elements each.

Any insights on why this would be happening would be much appreciated.

0条回答
登录 后发表回答