Skip to content

Instantly share code, notes, and snippets.

@mikepfeiffer
Created December 16, 2018 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikepfeiffer/1183c6c93e83d037551d8e0df21a23f8 to your computer and use it in GitHub Desktop.
Save mikepfeiffer/1183c6c93e83d037551d8e0df21a23f8 to your computer and use it in GitHub Desktop.
Client side code that uses fetch API to submit a form
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