title: get base64 image from image url using angular 2
body: <p>I'm trying to display images that their URLs comes from Flickr photo search API. I want to convert these image URLs to base64 so I can store the images in Session Storage and only call Flickr API if images do not exist in Session Storage:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>export class AComponent {
  
      results: any[];
      base64;
      constructor(private http: HttpClient, private jsonp: Jsonp, private router: Router,
          private storage: SessionStorageService) {
  
          if (!sessionStorage.getItem("results")) {
         
              this.http.get('https://api.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=378060923d01ccb122bd53491163355d&amp;tags=jungle&amp;per_page=5&amp;format=json&amp;nojsoncallback=1').subscribe(data =&gt; {
  
                  this.results = (&lt;RootObject&gt;data).photos.photo.map((photo) =&gt; {
  
                      return {
                          // url:`https://farm${photo.farm}.staticflickr.com/${photo.server}/${photo.id}_${photo.secret}_m.jpg`,
                          base64: this.base64, // this line how can I get base64 image from the above url
                          title: photo.title
                      }
  
                  });
                  sessionStorage.setItem("results", JSON.stringify(this.results));
              });
          }
          else {
  
              this.results = JSON.parse(sessionStorage.getItem("results"))
          }
  
      }
  
  }</code></pre>
  </div>
  </div>
  </p>