title: Convert image URL to dataURL - Javascript
body: <p>I am using react-native-facebook-login in order to get user data. Its returning me the url of the profile picture. when I paste this url in the browser the picture gets downloaded.
  Its returning the following string named profile</p>
  
  <pre><code>{"id":"10210xxx114564932","name":"Stan Shivam","email":"ansh1602@gmail.com","first_name":"Shivam","last_name":"Stan","age_range":{"min":21},"link":"https:\/\/www.facebook.com\/app_scoped_user_id\/10210663114564932\/","picture":{"data":{"height":50,"is_silhouette":false,"url":"https:\/\/lookaside.facebook.com\/platform\/profilepic\/?asid=10210663114564932&amp;height=50&amp;width=50&amp;ext=1523007905&amp;hash=AeQ-_PZnt1JTbnth","width":50}},"gender":"male","locale":"en_GB","timezone":5.5,"updated_time":"2018-03-27T18:37:33+0000","verified":true}
  </code></pre>
  
  <p>What I want to do is I want to convert the url to base64 and send it to server. But I am not being able to find some good tut on this.  </p>
  
  <p>What I tried so far.</p>
  
  <pre><code>getBase64ImageFromUrl = async (imageUrl) =&gt; {
      const res = await fetch(imageUrl);
      console.log(res);
      const blob = await res.blob();
  
      return new Promise((resolve, reject) =&gt; {
        const reader = new FileReader();
        reader.addEventListener('load', () =&gt; {
            resolve(reader.result);
        }, false);
  
        reader.onerror = () =&gt; {
          return reject(this);
        };
        reader.readAsDataURL(blob);
      });
    }; 
  </code></pre>
  
  <p>calling it from constructor</p>
  
  <pre><code>this.getBase64ImageFromUrl('https://lookaside.facebook.com/platform/profilepic/?asid=10210663114564932&amp;height=50&amp;width=50&amp;ext=1523007763&amp;hash=AeSavHT5oXVEMq4w')
              .then(result =&gt; console.log(result))
              .catch(err =&gt; console.error(err));
  </code></pre>
  
  <p>But it gives me res.blob() is not a function.
  What exactly do I need to use in order to achive it.</p>