title: nodejs : TypeError: callback is not a function
body: <p>I have written below code to read a xml and return a hashmap:</p>
  
  <pre><code>this.xmlObjectRepositoryLoader = function (xmlPath, callback){
          var map = {}
          var innerMap = {};
          var el;
          fs.readFile(xmlPath, "utf-8",function(err, data) {
              if(err){
                  console.log('File not found!!')
              }
              else{
                  console.log(data)
                  var doc = domparser.parseFromString(data,"text/xml");
                  var els = doc.getElementsByTagName("Child");
                  for(var i =0 ; i&lt; els .length;i++){
                      var e = elements[i];
                      eName = e.getAttribute("a");
                      var params = elm.getElementsByTagName("abc");
                      innerMap = {};
                      for(var j =0 ; j&lt; params.length;j++){
                          var param = params[j];
                          var b = param.getAttribute("b");
                          var c= param.getAttribute("c");
                          innerMap[b] = c;
                      }
                      map[el] = innerMap;
                      innerMap={};
                  };
              }
              console.log(map);
              return callback(map);
          });        
      };
  </code></pre>
  
  <p>And I am calling <code>xmlObjectRepositoryLoader</code> from below method but it returns error as <code>TypeError: callback is not a function</code>:</p>
  
  <pre><code>this.objectLoader = function(filePath){
          if (filePath.includes(".xml")) {
              console.log(this.xmlObjectRepositoryLoader(filePath));
      }
  </code></pre>
  
  <p>Can you please let me know where I am wrong and how can I resolve this</p>