title: How to write this xhr request in axios?
body: <p>How do I write the following code with Axios calls instead of <code>XMLHttpRequest</code>?</p>
  
  <pre class="lang-js prettyprint-override"><code>var xhr = new XMLHttpRequest;
  xhr.open("POST", "/attachments", true);
  /*open an ajax request.*/
  
  xhr.upload.onprogress = function(event) {
    var progress = event.loaded / event.total * 100;
    attachment.setUploadProgress(progress);
  };
  
  xhr.onload = function() {
    if (xhr.status === 201) {
      setTimeout(function() {
        var url = xhr.responseText;
        attachment.setAttributes({ url: url, href: url });
      }, 30)
    }
  };
  
  attachment.setUploadProgress(10);
  
  setTimeout(function() {
    xhr.send(attachment.file);
  }, 30)
  </code></pre>