async function upload() {
const input = document.querySelector('input[type="file"]');
const data = new FormData();
data.append("file", input.files[0]);
const response = await fetch('/files', {
method: 'POST',
body: data
});
const responseData = await response.json();
console.log(responseData);
}
Created
August 17, 2022 15:01
-
-
Save moosetraveller/1a137da1ad26efe522f1f608664acc7f to your computer and use it in GitHub Desktop.
Upload a File with Fetch API
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment