title: Javascript - how to solve "Uncaught error: undefinedModule"
body: <p>I'm using a Javascript file to try and get a token from ArcGIS Online. However, whenever I try it, it comes back with</p>
  
  <pre><code>init.js:11 Uncaught Error: undefinedModule
  </code></pre>
  
  <p>The file (GetAToken.js) is below:</p>
  
  <pre><code>dojo.ready(init);
  var request = dojo.require('request'); // npm install request
  
  // generate a token with your client id and client secret
  function getToken(callback) {
      request.post({
          url: 'https://www.arcgis.com/sharing/rest/oauth2/token/',
          json: true,
          form: {
              'f': 'json',
              'client_id': '&lt;&lt;MY_CLIENT_ID&gt;&gt;',
              'client_secret': '&lt;&lt;MY_CLIENT_SECRET&gt;&gt;',
              'grant_type': 'client_credentials',
              'expiration': '1440'
          }
      }, function (error, response, body) {
          console.log(body.access_token);
          callback(body.access_token);
      });
  }
  </code></pre>
  
  <p>And the bit which calls it (in a HTML file) is:</p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://esri.github.io/calcite-bootstrap/assets/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" href="https://js.arcgis.com/4.0/esri/css/main.css"&gt;
  &lt;script src="https://js.arcgis.com/4.0/"&gt;&lt;/script&gt;
  &lt;script src="GetAToken.js"&gt;
      var MyToken = callback(getToken);
      alert(MyToken);
  &lt;/script&gt;
  </code></pre>