JavaScript RestAngular get array of JSON objects

I'm trying to get JSON response from server using restangular.

  var baseAccounts = Restangular.one('getAllCustomers');
  baseAccounts.getList().then(function(customers) {
      $scope.myData = customers;
      console.log(customers);
    });

The problem is that I always get the response in following format:

0: Object
1: Object
2: Object
addRestangularMethod: function bound() {
all: function bound() {
allUrl: function bound() {
clone: function bound() {
customDELETE: function bound() {
customGET: function bound() {
customGETLIST: function bound() {

But I would like only structure of pure returned JSON. If could somebody put here example for RestAngular plugin I would be very glad.

Thanks for any help.

Answer:1

To make things simple you can use Restangular 1.4 and chain the plain() function on the response

baseAccounts.getList().then(function(customers){
 $scope.myDate = customers.plain();

});

Answer:2

Try this

var baseAccounts = Restangular.one('getAllCustomers');
  baseAccounts.getList().then(function(response) {
      $scope.myData = response.customers;
      console.log(response.customers);
    });
Answer:3

Can someone explain the following code? inputWords is supposed to be an array containing various words and this function is supposed to return an array containing the number of times a word appears in ...

Can someone explain the following code? inputWords is supposed to be an array containing various words and this function is supposed to return an array containing the number of times a word appears in ...

  1. javascript reduce function example
  2. javascript reduce function explained
  3. javascript reduce function array of objects
  4. javascript reduce function on object
  5. javascript reduce function mdn
  6. javascript reduce function implementation
  7. javascript reduce function
  8. javascript reduce function parameters
  9. javascript reduce function array
  10. javascript reduce function syntax
  11. javascript reduce function callback
  12. javascript reduce function calls
  13. javascript reduce arrow function
  14. javascript array reduce function example
  15. javascript reduce async function
  16. javascript map reduce function
  17. javascript reduce anonymous function
  18. javascript es6 reduce function
  19. javascript return reduce function
  20. javascript reduce is not a function

I have a directory with a bunch of jade templates, and a grunt task that compiles all of them to individual html files. I'd like to have a watch task that recompiles a template when it changes, but ...

I have a directory with a bunch of jade templates, and a grunt task that compiles all of them to individual html files. I'd like to have a watch task that recompiles a template when it changes, but ...

I am using node.js for an application, I'm also using mysql to allow users to connect on the app. I was using the application on local, and it was working pretty well, no crash, nothing bad. Today I ...

I am using node.js for an application, I'm also using mysql to allow users to connect on the app. I was using the application on local, and it was working pretty well, no crash, nothing bad. Today I ...

  1. node application crashes
  2. heroku app crashed node

I have the following controller action: var fileName = "monthly_report.pdf" var document = new Document(); //DO SOME STUFF WITH THE DOCUMENT MemoryStream stream = new MemoryStream(); ...

I have the following controller action: var fileName = "monthly_report.pdf" var document = new Document(); //DO SOME STUFF WITH THE DOCUMENT MemoryStream stream = new MemoryStream(); ...