title: Shopify - I can access a JSON object from the browser console, but not from the theme file
body: <p>I'm using the <code>GET/cart.js</code> call in an asset on my theme to get the cart contents in the form of a JSON object like this:</p>
  
  <pre><code>var response = jQuery.getJSON('/cart.js');
  </code></pre>
  
  <p>I then try to log to the console the contents of the object like this (<em>within the same snippet file, right after making the call</em>):</p>
  
  <pre><code>$( document ).ready(function() {
      console.log(response.responseJSON.items[0]);
  });
  </code></pre>
  
  <p>I get a <code>TypeError: response.responseJSON is undefined</code> within the console. If I try to log the same thing again within the console (<code>console.log(response.responseJSON.items[0]);</code>), it works and it prints the first item of the cart. </p>
  
  <p>I tried checking the object until it isn't <em>undefined</em> anymore with a <code>while</code> loop and I also tried console logging only after the page fully loaded.</p>
  
  <p>For sake of clarity, these are the full contents of my snippet:</p>
  
  <pre><code>var response = jQuery.getJSON('/cart.js');
  $( document ).ready(function() {
      console.log(response.responseJSON.items[0]);
  });
  </code></pre>
  
  <p>How can I make this work straight from my snippet file?</p>
  
  <p>EDIT: I should mention that the object is already parsed, so that's not the reason it's giving me <em>undefined</em>. I did try parsing it just for the sake of it, but it gave me another error.</p>
  
  <p>EDIT 2: Here's the JSON I get from the call:</p>
  
  <pre><code>{
    "readyState": 4,
    "responseText": "{\"token\":\"4472c3d68931e8fe2bff0afcca67a188\",\"note\":null,\"attributes\":{},\"original_total_price\":39800,\"total_price\":39800,\"total_discount\":0,\"total_weight\":0.0,\"item_count\":2,\"items\":[{\"id\":16640068878400,\"properties\":null,\"quantity\":2,\"variant_id\":16640068878400,\"key\":\"16640068878400:94cf8752e20f28a3f675ee10f8e5cc72\",\"title\":\"Compleu Abby - 60\",\"price\":19900,\"original_price\":19900,\"discounted_price\":19900,\"line_price\":39800,\"original_line_price\":39800,\"total_discount\":0,\"discounts\":[],\"sku\":\"2558\",\"grams\":0,\"vendor\":\"33 Aya\",\"taxable\":true,\"product_id\":1710662484032,\"gift_card\":false,\"url\":\"\\/products\\/compleu-abby?variant=16640068878400\",\"image\":\"https:\\/\\/cdn.shopify.com\\/s\\/files\\/1\\/0087\\/2500\\/4352\\/products\\/61_b38d4463-58b7-4569-bf0c-71b59fcb6e28.jpg?v=1544168500\",\"handle\":\"compleu-abby\",\"requires_shipping\":true,\"product_type\":\"\",\"product_title\":\"Compleu Abby\",\"product_description\":\"Compus din bluză dantelă cu tricot, eșarfă și pantalon tricot.\\n*eșarfa nu este inclusă în preț, este oferită cadou și poate varia în funcție de stocul disponibil\",\"variant_title\":\"60\",\"variant_options\":[\"60\"]}],\"requires_shipping\":true,\"currency\":\"RON\"}",
    "responseJSON": {
      "token": "4472c3d68931e8fe2bff0afcca67a188",
      "note": null,
      "attributes": {},
      "original_total_price": 39800,
      "total_price": 39800,
      "total_discount": 0,
      "total_weight": 0,
      "item_count": 2,
      "items": [
        {
          "id": 16640068878400,
          "properties": null,
          "quantity": 2,
          "variant_id": 16640068878400,
          "key": "16640068878400:94cf8752e20f28a3f675ee10f8e5cc72",
          "title": "Compleu Abby - 60",
          "price": 19900,
          "original_price": 19900,
          "discounted_price": 19900,
          "line_price": 39800,
          "original_line_price": 39800,
          "total_discount": 0,
          "discounts": [],
          "sku": "2558",
          "grams": 0,
          "vendor": "33 Aya",
          "taxable": true,
          "product_id": 1710662484032,
          "gift_card": false,
          "url": "/products/compleu-abby?variant=16640068878400",
          "image": "https://cdn.shopify.com/s/files/1/0087/2500/4352/products/61_b38d4463-58b7-4569-bf0c-71b59fcb6e28.jpg?v=1544168500",
          "handle": "compleu-abby",
          "requires_shipping": true,
          "product_type": "",
          "product_title": "Compleu Abby",
          "product_description": "Compus din bluză dantelă cu tricot, eșarfă și pantalon tricot.\n*eșarfa nu este inclusă în preț, este oferită cadou și poate varia în funcție de stocul disponibil",
          "variant_title": "60",
          "variant_options": [
            "60"
          ]
        }
      ],
      "requires_shipping": true,
      "currency": "RON"
    },
    "status": 200,
    "statusText": "OK"
  }
  </code></pre>