title: unable to get property 'd' of undefined or null reference
body: <p>I am querying my SharePoint 2013 list using a promise but I get an abnormal behavior.  As you will see from my code below, the value of 'promise.responseJSON.d.results.length == 1' condition returns an error but if I comment out the if statement generating and console.log(promise.responseJSON.d.results.length), I get a value of 1.  I don't understand why this is happening. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    var promise = getData();
    promise.done(function(data) {
      return data;
    });
  
    console.log(typeof(promise));
  
    //returns an error 'unable to get property 'd' of undefined or null reference
    if (promise.responseJSON.d.results.length === 1) {
      alert("show ED DOM Elements");
    } else {
      alert("Do not show ED DOM Elements");
    }
    console.log(promise.responseJSON.d.results.length); //returns 1 if I comment out the if statement above
  
  });
  
  function getData() {
    //console.log(itemID);
    var itemID = getQueryString("ID");
    var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbyTitle('Document Approval')/items?$filter=(BackToAD eq 'Yes') and  (ID eq " + itemID + ")";
    console.log(endPointUrl);
  
    var headers = {
      "accept": "application/json;odata=verbose"
    };
  
    return $.ajax({
      url: endPointUrl,
      type: "GET",
      headers: headers
  
    });
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>image of returned object from promise showing that 'd' does exist
  <a href="https://i.stack.imgur.com/PEwie.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PEwie.jpg" alt="enter image description here"></a></p>
  
  <p>Any help and insight would be much appreciated. This has been driving me crazy for a few hours.</p>
  
  <p>Thanks!</p>