ahmadnassri/httpsnippet

View on GitHub
src/targets/javascript/xhr/fixtures/multipart-file.js

Summary

Maintainability
A
50 mins
Test Coverage
const data = new FormData();
data.append('foo', 'test/fixtures/files/hello.txt');

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'http://mockbin.com/har');

xhr.send(data);