title: JSON.parse() fails in AngularJS TransformResponse
body: <p>I am trying to GET from Wattpad.com's API level 3, <a href="http://www.wattpad.com/api/v3/stories/" rel="nofollow">http://www.wattpad.com/api/v3/stories/</a>, using</p>
  
  <p>Service</p>
  
  <pre><code>angular.module('myApp')
    .service('WattpadService', function WattpadService($resource) {
        var resource = $resource('http://www.wattpad.com/api/v3/stories', {}, {
          query: {method:'GET',
                  params:{query:'margaretatwood'},
                  isArray:false
                   }   
        }); 
        return {
          loadStories: function() {
            return resource.query();
          }   
        };  
    }); 
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>angular.module('myApp')
    .controller('MainCtrl', function ($scope, WattpadService, $resource) {
      WattpadService.loadStories()
      .$promise.then(
        function(data) {
          console.log("success");
          console.log(data);
        },  
        function(response) {
          console.log(response);
        }   
      );  
  
  });
  </code></pre>
  
  <p>The data I get back is from console.log is super strange:</p>
  
  <pre><code>Resource
  0: "a"
  1: "r"
  2: "r"
  3: "a"
  4: "y"
  5: " "
  6: "("
  7: "↵"
  (etc)
  </code></pre>
  
  <p>As far as I can tell, I'm experiencing the problem described at <a href="http://mariuszprzydatek.com/2013/12/13/tricky-behavior-of-angularjs-resource-service/" rel="nofollow">http://mariuszprzydatek.com/2013/12/13/tricky-behavior-of-angularjs-resource-service/</a>. Using transformResponse like:</p>
  
  <pre><code>query: {method:'GET',
      params:{query:'margaretatwood'},
      isArray:false,
      transformResponse: function(data, headers){
      return JSON.parse(data);
      }
  } 
  </code></pre>
  
  <p>Gets me</p>
  
  <pre><code>SyntaxError: Unexpected token a
      at Object.parse (native)
  </code></pre>
  
  <p>Any advice?</p>
  
  <p><strong>EDIT</strong> console.log of data before it's parsed (using a random user with only 1 story instead of Atwood who has a lot.)</p>
  
  <pre><code>array (
    'stories' =&gt; 
    array (
      0 =&gt; 
      array (
        'id' =&gt; '18265912',
        'title' =&gt; 'A Little Something Different',
        'length' =&gt; 9370,
        'createDate' =&gt; '2014-06-23T21:48:55Z',
        'modifyDate' =&gt; '2014-07-15T18:24:45Z',
        'voteCount' =&gt; 20,
        'readCount' =&gt; 153,
        'commentCount' =&gt; 4,
        'language' =&gt; 
        array (
          'id' =&gt; 1,
          'name' =&gt; 'English',
        ),
        'user' =&gt; 
        array (
          'name' =&gt; 'iamsandyhall',
          'avatar' =&gt; 'http://a.wattpad.com/useravatar/iamsandyhall.128.340656.jpg',
        ),
        'description' =&gt; 'Lea and Gabe are in the same creative writing class. They get the same pop culture references, order the same Chinese food, and hang out in the same places. Unfortunately, Lea is reserved, Gabe has issues, and despite their initial mutual crush, it looks like they are never going to work things out.
  
  But somehow even when nothing is going on, something is happening between them, and everyone can see it. Their creative writing teacher pushes them together. The baristas at the local Starbucks watch their relationship like a TV show. Their bus driver tells his wife about them. The waitress at the diner automatically seats them together. Even the squirrel who lives on the college green believes in their relationship.',
        'cover' =&gt; 'http://a.wattpad.com/cover/18265912-256-k534988.jpg',
        'completed' =&gt; false,
        'categories' =&gt; 
        array (
          0 =&gt; 1,
          1 =&gt; 4,
        ),
        'tags' =&gt; 
        array (
          0 =&gt; 'adult',
          1 =&gt; 'contemporary',
          2 =&gt; 'reads',
          3 =&gt; 'swoon',
          4 =&gt; 'swoonworthy',
          5 =&gt; 'young',
        ),
        'rating' =&gt; 3,
        'copyright' =&gt; 1,
        'url' =&gt; 'http://www.wattpad.com/story/18265912-a-little-something-different',
        'firstPartId' =&gt; 56140494,
        'numParts' =&gt; 3,
        'parts' =&gt; 
        array (
          0 =&gt; 
          array (
            'id' =&gt; 56140494,
            'title' =&gt; 'A Little Something Different (September and October)',
            'draft' =&gt; false,
            'modifyDate' =&gt; '2014-07-14T19:45:12Z',
            'length' =&gt; 723,
            'videoId' =&gt; '',
            'photoUrl' =&gt; '',
            'commentCount' =&gt; 1,
            'voteCount' =&gt; 6,
            'readCount' =&gt; '91',
          ),
          1 =&gt; 
          array (
            'id' =&gt; 56140699,
            'title' =&gt; 'September (Maribel - Lea\'s roommate)',
            'draft' =&gt; false,
            'modifyDate' =&gt; '2014-07-14T19:48:02Z',
            'length' =&gt; 2611,
            'videoId' =&gt; '',
            'photoUrl' =&gt; '',
            'commentCount' =&gt; 0,
            'voteCount' =&gt; 6,
            'readCount' =&gt; '37',
          ),
          2 =&gt; 
          array (
            'id' =&gt; 56140763,
            'title' =&gt; 'September (Inga - creative writing professor)',
            'draft' =&gt; false,
            'modifyDate' =&gt; '2014-07-15T18:21:20Z',
            'length' =&gt; 6036,
            'videoId' =&gt; '',
            'photoUrl' =&gt; '',
            'commentCount' =&gt; 3,
            'voteCount' =&gt; 8,
            'readCount' =&gt; '27',
          ),
        ),
        'deleted' =&gt; false,
      ),
    ),
    'total' =&gt; 1,
    'categories' =&gt; 
    array (
      0 =&gt; 
      array (
        'id' =&gt; 4,
        'name' =&gt; 'Romance',
        'count' =&gt; 1,
      ),
      1 =&gt; 
      array (
        'id' =&gt; 1,
        'name' =&gt; 'Teen Fiction',
        'count' =&gt; 1,
      ),
    ),
    'tags' =&gt; 
    array (
    ),
  )
  </code></pre>
  
  <p>typeof(data) returns <code>string</code></p>
  
  <p>oh - seems to be a php array</p>