Skip to content

Instantly share code, notes, and snippets.

Last active September 7, 2022 18:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Formdata: Usage of the FormData object
const newsletterForm = document.getElementById('newsletter-form');
newsletterForm.addEventListener('submit', () => {
const formData = new FormData(newsletterForm);
const name = formData.get('name');
// Append timestamp
// Delete timestamp
// Set name
formData.set('name', 'John Doe');
// Loop through formData
for (const [key, value] of formData) {
console.log(key, value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment