I am trying to process the response from REST Api but unable to do it as it is wrapped around a callback function using $resource in my angularjs application:
Service code:
apiService.factory("TestQuality", function ($resource) {
var _url = "http://test.amat.com:8080/TestDashboard/TestQualityServlet";
return $resource(_url, {}, {
"query": {
method: "GET",
headers: {
'Content-Type': 'application/json'
}
}
});
});
Controller code:
..
.
var keyword = $scope.keyword ? $scope.keyword : '';
var paramsObj = {};
paramsObj['query'] = keyword;
paramsObj['callback'] = jsonp_callback;
$scope.testQualityPromise = TestQuality.query(paramsObj, function(response) {
if (response && response.data.response.values && response.data.response.values.length > 0) {
$scope.noData = false;
$scope.testQualityData = response.data.response.values;
$scope.testQualityTblData = new NgTableParams(
{
},
{ counts: [], dataset: $scope.testQualityTblData });
} else {
$scope.noData = true;
}
});
.. .
Response from REST API:
testqualitycallback({
"data": {
"response": [{
"matches": 1,
"ngroups": null,
"values": [{
"groupValue": "0010-02233",
"result": [{
"afr_total_rejects_qty": 1,
"afr_systems_count": 149,
"afr_total_shipments_qty": 150.0,
"afr_percent": 0.6622516556291391
}]
}],
"name": "test_number"
}]
}
})
Above code is not giving me the desired respone; need suggestions for handling this response to get the resultset shown to the view.