DanteAdmin
asked on
JSON nested response not displaying
We are talking to an API and most of the calls are doing what we expect, but there's one set of calls I just get blank rows from and as many other clients can use it I must be doing something wrong
In my "controller.js" I have this
####
$http.get('/rest/queue/54' ).
success(function(data, status, headers, config) {
$scope.customers = data;
}).
error(function(data, status, headers, config) {
// log error
});
####
This is what I get returned when making the call from the command line:
####
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/json
Content-Length: 666
Date: Sun, 02 Nov 2014 15:18:40 GMT
{"shortName":"XYZX","clien tName":"Th e Amazing One","queueSize":2,"queueD etails":[{ "user":{"n ame":"Mark us Sweden","email":"markus@sw eden.com", "phoneNumb er":"46730 773743","i d":514,"ac tivated":f alse,"pin" :"6592","u sersQueues ":[]},"par tySize":3, "timeEnter edQueue":1 3844978840 00,"entryS tatus":"NO TIFIED","e stimatedWa itingTime" :30,"userM essage":nu ll,"id":97 ,"notes":" "},{"user" :{"name":" Miky","ema il":"Miky@ hotmail.co m","phoneN umber":"44 785353533" ,"id":8,"a ctivated": false,"pin ":"6363"," usersQueue s":[]},"pa rtySize":7 ,"timeEnte redQueue": 1384509850 000,"entry Status":"N OTIFIED"," estimatedW aitingTime ":65,"user Message":n ull,"id":9 8,"notes": "Tall, striped jumper "}]}
####
And then on the webpage this:
####
<tr ng-repeat="customer in customers">
<td>{{customer.shortName}} </td>
<td>{{customer.queueDetail s.user.nam e}}</td>
</tr>
####
It's looping through and giving me back two rows as there's two entries, and if there's 12 I get 12 rows back but no data
I'm making a similar call which is working fine, that code below
Controller.js
####
$http.get('/rest/users/').
success(function(data, status, headers, config) {
$scope.customers = data;
}).
error(function(data, status, headers, config) {
// log error
});
####
This is what I get returned when making the call from the command line:
####
[{"name":"Thomas","email": "user@emai l.com","ph oneNumber" :"44790135 3380","id" :2,"activa ted":false ,"pin":"43 40","users Queues":[] },{"name": "Jim Ant","email":"jam@ial.co.u k","phoneN umber":"44 7868439992 ","id":4," activated" :false,"pi n":"4397", "usersQueu es":[]}]
####
And then on the webpage this:
####
<tr ng-repeat="customer in customers">
<td>{{customer.name}}</td>
<td>{{customer.email}}</td >
</tr>
####
This last one works just fine
It is me not using the right syntax when the JSON return is nested or something else I'm doing wrong ?
In my "controller.js" I have this
####
$http.get('/rest/queue/54'
success(function(data, status, headers, config) {
$scope.customers = data;
}).
error(function(data, status, headers, config) {
// log error
});
####
This is what I get returned when making the call from the command line:
####
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/json
Content-Length: 666
Date: Sun, 02 Nov 2014 15:18:40 GMT
{"shortName":"XYZX","clien
####
And then on the webpage this:
####
<tr ng-repeat="customer in customers">
<td>{{customer.shortName}}
<td>{{customer.queueDetail
</tr>
####
It's looping through and giving me back two rows as there's two entries, and if there's 12 I get 12 rows back but no data
I'm making a similar call which is working fine, that code below
Controller.js
####
$http.get('/rest/users/').
success(function(data, status, headers, config) {
$scope.customers = data;
}).
error(function(data, status, headers, config) {
// log error
});
####
This is what I get returned when making the call from the command line:
####
[{"name":"Thomas","email":
####
And then on the webpage this:
####
<tr ng-repeat="customer in customers">
<td>{{customer.name}}</td>
<td>{{customer.email}}</td
</tr>
####
This last one works just fine
It is me not using the right syntax when the JSON return is nested or something else I'm doing wrong ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
####
...pin":"6592","usersQueue
Everything before that I can get to but nothing after
Is there a way for me to ignore that there is no data and continue, or do we have to fix that on the API side that outputs the JSON ?