Reputation: 11642
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.
Upvotes: 2
Views: 2273
Reputation: 189
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();
});
Upvotes: 5
Reputation: 447
I am also looking for an answer to this. I have not found anything better, so I implemented that way.
var baseAccounts = Restangular.one('getAllCustomers');
baseAccounts.getList().then(function(customers) {
var tmp = [];
customers.forEach(function(element){
tmp.push(element);
});
$scope.myData = tmp;
console.log(customers);
});
then the return will be
0: Object
1: Object
2: Object
Upvotes: 0
Reputation: 909
Try this
var baseAccounts = Restangular.one('getAllCustomers');
baseAccounts.getList().then(function(response) {
$scope.myData = response.customers;
console.log(response.customers);
});
Upvotes: 0