title: Facebook Javascript SDK uncaught TypeError: Cannot read property 'userID' of undefined
body: <p>I am trying to implement an authorization feature using the Facebook JavaScript SDK. When I run it, it and check the console I see the error. </p>
  
  <pre><code>uncaught TypeError: Cannot read property 'userID' of undefined 
  </code></pre>
  
  <p>Code snippet</p>
  
  <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;!-- Load the Facebook JavaScript SDK --&gt;
  &lt;script src="//connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  var appId = 'APP_ID';
  var uid;
  
  // Initialize the JS SDK
  FB.init({
   appId: '413026618765431',
   cookie: true,
  });
  
  // Get the user's UID
  FB.getLoginStatus(function(response) {
   uid = response.authResponse.userID ? response.authResponse.userID : null;
  });
  
  function authUser() {
   FB.login(function(response) {
     uid = response.authResponse.userID ? response.authResponse.userID : null;
   }, {scope:'email,publish_actions'});
  }
  &lt;/script&gt;
  </code></pre>