We can use the following code inside a click
event handler of a button which performs the uploading:
const fileEle = document.getElementById('upload');
upload(fileEle, '/path/to/back-end').then(function(response) {
// `response` is what we got from the back-end
// We can parse it if the server returns a JSON
const data = JSON.parse(response);
...
});