Skip to content

Instantly share code, notes, and snippets.

@tlux
Created January 31, 2021 18:41
Show Gist options
  • Select an option

  • Save tlux/c4c2e3e49327043124d29036dc6ba82e to your computer and use it in GitHub Desktop.

Select an option

Save tlux/c4c2e3e49327043124d29036dc6ba82e to your computer and use it in GitHub Desktop.
FormData to object (Typescript)
export function formDataToObject(formData: FormData): Record<string, FormDataEntryValue> {
const data: Record<string, FormDataEntryValue> = {};
for (let [key, value] of formData.entries()) {
data[key] = value;
}
return data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment