Expected response to contain an object but got an array

3,586 views
Skip to first unread message

cyprien...@gmail.com

unread,
Jan 6, 2014, 8:09:44 AM1/6/14
to ang...@googlegroups.com
Hello,
I'm trying to make a tutorial to use Angular with a Drupal backend.
For that, Drupal provide JSON data and i try to use it with AngularJS. I've decided to work with the Angular-phonecat tutorial.
Here is the JSON code provided by Drupal 7 for a phone detail (the list is working fine) :

[{"node_title":"Dell Streak 7","description":"Introducing Dell\u2122 Streak 7. Share photos, videos and movies together. It\u2019s small enough to carry around, big enough to gather around. Android\u2122 2.2-based tablet with over-the-air upgrade capability for future OS releases. A vibrant 7-inch, multitouch display with full Adobe\u00ae Flash 10.1 pre-installed. Includes a 1.3 MP front-facing camera for face-to-face chats on popular services such as Qik or Skype. 16 GB of internal storage, plus Wi-Fi, Bluetooth and built-in GPS keeps you in touch with the world around you. Connect on your terms. Save with 2-year contract or flexibility with prepaid pay-as-you-go plans"}]


And i've this error :
Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an object but got an array

I've nearly the same code as in the angular tutorial (services.js) :
'use strict';

/* Services */

var phonecatServices = angular.module('phonecatServices', ['ngResource', 'ngSanitize']);

phonecatServices.factory('Phone', ['$resource',
  function($resource){
    return  $resource('http://ng-drupal.tld/drupal/phone-list/views/phone.json?args[0]=:phoneId', {}, {
      query: {method:'GET', params:{phoneId:'phones'}, isArray:true}
    });
  }]);

phonecatServices.factory('Phones', ['$resource',
  function($resource){
    return $resource('http://ng-drupal.tld/drupal/phone-list/views/phone_list.json', {}, {
      query: {method:'GET', isArray:true}
    });
  }]);


I've changes the option isArray:true but the error is the same.
Any suggestions ?

PS : Sorry for my poor english, feel free to correct me...

Pablo Moran

unread,
Oct 11, 2014, 5:36:58 AM10/11/14
to ang...@googlegroups.com
Hey buddy! I am having similar issues, try changing isArray=true to false. Hope this helps.
Reply all
Reply to author
Forward
0 new messages