title: Read content of SP.File object as text using JSOM
body: <p>as the title suggests, I am trying to read the contents of a simple text file using JSOM. I am using a Sharepoint-hosted addin for this, the file I am trying to read resides on the host web in a document library.</p>
  
  <p>Here's my JS code:</p>
  
  <pre><code>function printAllListNamesFromHostWeb() {
      context = new SP.ClientContext(appweburl);
      factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
      context.set_webRequestExecutorFactory(factory);
      appContextSite = new SP.AppContextSite(context, hostweburl);
  
      this.web = appContextSite.get_web();
      documentslist = this.web.get_lists().getByTitle('Documents');
  
      var camlQuery = new SP.CamlQuery();
      camlQuery.set_viewXml('&lt;View&gt;&lt;ViewFields&gt;&lt;FieldRef Name="Name"/&gt;&lt;/ViewFields&gt;&lt;/View&gt;');
      listitems = documentslist.getItems(camlQuery);
  
      context.load(listitems, 'Include(File,FileRef)');
  
      context.executeQueryAsync(
          Function.createDelegate(this, successHandler),
          Function.createDelegate(this, errorHandler)
      );
  
      function successHandler() {
          var enumerator = listitems.getEnumerator();
          while (enumerator.moveNext()) {
              var results = enumerator.get_current();
              var file = results.get_file();
  
              //Don't know how to get this to work...
              var fr = new FileReader();
              fr.readAsText(file.get);
          }
      }
  
      function errorHandler(sender, args) {
          console.log('Could not complete cross-domain call: ' + args.get_message());
      }
  }
  </code></pre>
  
  <p>However, in my succes callback function, I don't know how I can extract the contents of the SP.File object. I tried using the FileReader object from HTML5 API but I couldn't figure out how to convert the SP.File object to a blob. </p>
  
  <p>Can anybody give me a push here? </p>