add test, update tags, update description

This commit is contained in:
Nikita
2019-03-15 12:54:57 +03:00
parent eaaa456ec6
commit 76e6286c98
10 changed files with 123 additions and 59 deletions

View File

@@ -1,6 +1,6 @@
### serializeForm
Serializes a form into an object.
Encode a set of form elements as a query string.
First we transform the `form` into `FormData`, then we convert it into an `array` and from the `array` we collect an `query string`
@@ -9,13 +9,6 @@ const serializeForm = form =>
Array.from(new FormData(form), field => field.map(encodeURIComponent).join('=')).join('&')
```
```html
<form id="form">
<input name="email" type="email" />
<input name="name" />
</form>
```
```js
serializeForm(document.querySelector('#form')) // email=test%40email.com&name=Test%20Name
```