title: Aurelia: How to handle a async request in a view?
body: <p>I have a dotnet core api that returns a FileContentResult..</p>
  
  <pre><code>return new FileContentResult(bytes, contentType)
  {
      FileDownloadName = Path.GetFileName(request.Filename)
  };
  </code></pre>
  
  <p>Via postman I can read out the image perfectly fine. Now I want to read the image, via the aurelia fetch client, and show it in my html view. This is my function to retrieve the image from the api.</p>
  
  <pre><code>public image(filename: string) {
      return this.http.fetch(AppConfiguration.base_url + 'assets/image',
          {
              method: 'post',
              body: json({
                  filename: filename
              })
          });
  }
  </code></pre>
  
  <p>I've tried to convert the blob in the response with this value converter. But I can't get that to work</p>
  
  <p>Converter:</p>
  
  <pre><code>export class BlobToUrlValueConverter {
      public toView(blob) {
          return URL.createObjectURL(blob);
      }
  }
  </code></pre>
  
  <p>Viewmodel:</p>
  
  <pre><code>export class Dashboard {
  
      public blob: any;
  
      constructor(
          public assets_service: AssetsService
      ) { }
  
      async attached() {
          let response = await this.assets_service.image('test.png');
          this.blob = response.blob();
      }
   }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>&lt;div if.bind="blob"&gt;
     ${ blob | blobToUrl }
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm not sure this is the right approach. Also not sure how handle the async request part of it either. What is the best way to get that image response to show in the html view? Lets say via a img tag?</p>