Created
October 30, 2020 18:13
-
-
Save bunnyhawk/eca4605af72f7145be5cfa483cf1663d to your computer and use it in GitHub Desktop.
aws nodemailer example submit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const API_URL = 'https://XXXXXXXXX.execute-api.us-west-2.amazonaws.com/dev/send-mail'; | |
const onSubmit = async (event) => { | |
event.preventDefault(); | |
submitButton.disabled = true; | |
const { submissionProof, ...rest } = Object.fromEntries(new FormData(event.target).entries()); | |
const body = new FormData(); | |
Object.keys(rest).forEach((name) => { | |
body.append(name, rest[name]); | |
}); | |
[...fileSubmit.files].forEach((file) => { | |
body.append(file.name, file); | |
}); | |
try { | |
const response = await fetch(API_URL, { | |
method: 'POST', | |
body, | |
}); | |
} catch (err) { | |
submitButton.disabled = false; | |
} | |
submitButton.disabled = false; | |
window.location.href = '/submitted/'; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment