[英]Error while parsing JSON response using $http
[
{
"dueAmount": 400,
"paidAmount": 0,
"balanceAmount": 400,
"invoiceNo": "VA019_203829",
"planName": null,
"schemeName": null,
"connectionStatus": null
}
]
I'm getting this response from postman. 我收到邮递员的回复。 But when i try to read these contents from my page, it returns " Undefined "
但是,当我尝试从我的页面读取这些内容时,它将返回“ Undefined ”
$http({
method:'POST',
url: 'http://10.10.1.200:8081/SelfCare/customer/getInvoiceDetails',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
data: JSON.stringify(getID)
}).then(function (response) {
$scope.invoice = response.invoiceNo;
alert($scope.invoice);
}
its always alerting undefined 它总是警报未定义
You need to do a change replace $scope.invoice = response.invoiceNo;
您需要进行更改,替换
$scope.invoice = response.invoiceNo;
by $scope.invoice = response.data[0].invoiceNo;
通过
$scope.invoice = response.data[0].invoiceNo;
Your response will get encapsulated into data
. 您的响应将被封装到
data
。
Use 采用
$scope.invoice = response.data[0].invoiceNo;
Instead of 代替
$scope.invoice = response.invoiceNo;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.