title: How to return ArrayBuffer from $http request in Node.js?
body: <p>I sent a <code>$http.post</code> request from Angular.js to Node.js in order to get an <code>ArrayBuffer</code> as following:</p>
  
  <pre><code>$http.post('/api/scholarships/load/uploaded-files', Global.user, {responseType:'arraybuffer'}).success(function(ab){
      console.log(ab); // Return ArrayBuffer {}
  });
  </code></pre>
  
  <p>Then, in Node.js, I retrieved uploaded files data and transform a <code>Buffer</code> object to <code>ArrayBuffer</code> object:</p>
  
  <pre><code>exports.loadUploadedFiles = function(req, res) {
      db.UserFile.findAll().success(function(files) {
          var buffer = files[0].dataValues.data; // Get buffer
          var arrayBuffer = new ArrayBuffer(buffer.length); // Start transforming Buffer to ArrayBuffer
          var views = new Uint8Array(arrayBuffer);
          for(var i = 0; i &lt; buffer.length; ++i) {
              views[i] = buffer[i];
          }
          res.type('arraybuffer');
          res.send(arrayBuffer); // Send the ArrayBuffer object back to Angular.js
      }).error(function(err) {
          console.log(err);
          res.sendStatus(500);
      });
  };
  </code></pre>
  
  <p>When I tried to print the response from above <code>$http.post</code>, I always got <code>ArrayBuffer{}</code>. What did I do wrong? Any help would be appreciated.</p>