title: Using a json file to store configurations for a dojo application
body: <p>I am writing a fontend web app using dojo that does a lot of calls to rest endpoints using xhr. I would like to have a place to store configurations for things like endpoint locations and html tag references. I thought I would use an xhr call to a json file to do this, but I am having trouble getting my functions to trigger in the right order/at all. Below is my main js file which has an init() function that I am passing as the callback to my conf initializer ("ebs/conf") module, also below. I have used the Chrome debugger to set breakpoints within my conf.get() method, and it looks as though it never gets called.</p>
  
  <p>Can someone give me some advice please?</p>
  
  <p>Main JS File:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>// module requirements
  require([ "dojo/dom", "dojo/on", "ebs/prices", "ebs/cart", "ebs/conf",
      "dojo/ready" ], function(dom, on, prices, cart, conf, ready) {
  
  ready(function() {
  
      conf.get("/js/config.json", init());
  
      function init(config) {
  
          on(dom.byId("height"), "keyup", function(event) {
              prices.calculate(config);
          });
          on(dom.byId("width"), "keyup", function(event) {
              prices.calculate(config);
          });
          on(dom.byId("qty"), "keyup", function(event) {
              prices.calculate(config);
          });
          on(dom.byId("grills"), "change", function(event) {
              prices.calculate(config);
          });
  
          cart.putSampleCart();
          cart.load(config);
  
      }
  
  });
  
  });
  </code></pre>
  
  <p>And here is my 'conf' module ("ebs/conf"):</p>
  
  <pre class="lang-javascript prettyprint-override"><code>define(["dojo/json", "dojo/request/xhr"], function(json, xhr) {
  return {
      get : function(file, callback) {
          // Create config object from json config file
          var config = null;
          xhr(file, {
              handleAs : "json"
          }).then(function(config) {
              callback(config);
          }, function(error) {
              console.error(error);
              return error;
          });
      }
  }
  });
  </code></pre>