Created
December 16, 2018 19:33
-
-
Save mikepfeiffer/1183c6c93e83d037551d8e0df21a23f8 to your computer and use it in GitHub Desktop.
Client side code that uses fetch API to submit a form
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
function submitMessage(e) { | |
e.preventDefault(); | |
let name = document.getElementById('name').value; | |
fetch('<YOUR FUNCTION URL GOES HERE>', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json, text/plain, */*', | |
'Content-type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
name: name | |
}) | |
}) | |
.then((res) => processResponse(res)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment