@ambitiondev/form-utils
v0.0.3
Published
A bundle of form utilities for usage in your (web)app
Downloads
6
Maintainers
Readme
Ambitiondev Form utils
This bundle contains some useful form utilities to use in your (web)app.
..
Table of contents
| | | |----|-----------------------| | 1. | Installation | | 2. | Features |
1. Installation
Simply execute the following:
npm i @ambitiondev/form-utils --saveor:
yarn add @ambitiondev/form-utils2. Features
formDataToJson
This function converts your formdata entries to a JSON-object. Useful for endpoints that require JSON in stead of form data.
usage:
import { formDataToJSON } from '@ambitiondev/form-utils'
const form = document.querySelector('form');
const data = new FormData(form);
...
const processedData = formDataToJSON(data);This should return your form data as an object, like so:
{
"name": "[email protected]",
"address": "Ambition street 4",
...
}