arraysjsonangularhttporacle-rest-data-services

Connecting ORDS to Angular


I have json format data that I am retrieving from my ORDS server and it looks like this:

{"items":[{"cust_code":"C00013","cust_name":"Holmes","cust_city":"London ","working_area":"London","cust_country":"UK","grade":2,"opening_amt":6000,"receive_amt":5000,"payment_amt":7000,"outstanding_amt":4000,"phone_no":"BBBBBBB","agent_code":"A003 "},{"cust_code":"C00001","cust_name":"Micheal","cust_city":"New York
","working_area":"New York","cust_country":"USA","grade":2,"opening_amt":3000,"receive_amt":5000,"payment_amt":2000,"outstanding_amt":6000,"phone_no":"CCCCCCC","agent_code":"A008 "},{"cust_code":"C00020","cust_name":"Albert","cust_city":"New York
","working_area":"New York","cust_country":"USA","grade":3,"opening_amt":5000,"receive_amt":7000,"payment_amt":6000,"outstanding_amt":6000,"phone_no":"BBBBSBB","agent_code":"A008 "},{"cust_code":"C00025","cust_name":"Ravindran","cust_city":"Bangalore ","working_area":"Bangalore","cust_country":"India","grade":2,"opening_amt":5000,"receive_amt":7000,"payment_amt":4000,"outstanding_amt":8000,"phone_no":"AVAVAVA","agent_code":"A011 "},{"cust_code":"C00015","cust_name":"Stuart","cust_city":"London
","working_area":"London","cust_country":"UK","grade":1,"opening_amt":6000,"receive_amt":8000,"payment_amt":3000,"outstanding_amt":11000,"phone_no":"GFSGERS","agent_code":"A003 "}],"hasMore":false,"limit":25,"offset":0,"count":5,"links":[{"rel":"self","href":"http://localhost:9000/ords/demo/customers/getAll/"},{"rel":"describedby","href":"http://localhost:9000/ords/demo/metadata-catalog/customers/getAll/"},{"rel":"first","href":"http://localhost:9000/ords/demo/customers/getAll/"}]}

so I was wondering if there is a way to to break down the items part and to put it in a tables using anguler.

I tried to use this way in my ts file:

http.get('http://localhost:9000/ords/demo/customers/getAll/')
    .subscribe(data => this.items = data);

But I keep getting this error:

Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed


Solution

  • The array you want is in the items property so you have to do

    http.get('http://localhost:9000/ords/demo/customers/getAll/')
        .subscribe(data => this.items = data.items);