title: Convert upload file to byte array to be sent to API request in Angular/Typescript
body: <p>How can I convert a uploaded file to byte array in <em>Angular/Typescript</em>?</p>
  
  <p>Component.ts</p>
  
  <pre><code> buildRequest(): CreateRequest { 
   var reader = new FileReader();  
      return {
        create: {
          fileData: this.reader.readAsArrayBuffer(this.fileToUpload)        
        }
      };
    }
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>export interface CreateRequest {
      create: {
        fileData: Uint8Array[]; // Also, is this correct representation of byte array?
      };
    }
  
  </code></pre>
  
  <p>Currently, I am getting an error when I am assigning <code>ReadAsArrayBuffer</code> function to fileData - </p>
  
  <blockquote>
    <p>"Type 'void' is not assignable to type 'Uint8Array[]'"</p>
  </blockquote>
  
  <p>.</p>
  
  <p>What is the correct way of sending byte array to API request?</p>