🕉 @feelinglovelynow/get-form-entries
💎 Install
pnpm add @feelinglovelynow/get-form-entries
🤓 Unit Tests
🙏 Description
- Recieves Form Data and responds with an Object
- Converts
<input name="foo" value="bar" />
into{ foo: 'bar' }
- Converts
<input name="image" />
into{ image: File }
- Converts
<input name="images" multiple />
into{ images: File[] }
- If the input support multiple but only 1 file is uploaded =>
{ image: File }
- An array is used for a response value only if multiple files share the same form name (example below)
💚 Example
- Implementation
import { getFormEntries } from '@feelinglovelynow/get-form-entries'
const fields = getFormEntries(formData)
- formData
FormData <entries>
0: message → "Hello World!"
1: images → File
<key>: "images"
<value>: File
2: images → File
<key>: "images"
<value>: File
3: images → File
<key>: "images"
<value>: File
- Response from
getFormEntries(formData)
{
message: 'Hello World!',
images: [
File {
size: 93146,
type: 'image/jpeg',
name: 'glew-fl.jpg',
lastModified: 1683003052322
},
File {
size: 64056,
type: 'image/jpeg',
name: 'violet flame.jpg',
lastModified: 1683003052322
},
File {
size: 46030,
type: 'image/jpeg',
name: 'violet-flame.jpg',
lastModified: 1683003052323
}
]
}
🔥 Errors we may throw
getFormEntries()
if (!(data instanceof FormData)) throw { id: 'fln__get-form-entries__invalid-data', message: 'Please pass getFormEntries() FormData', _errorData: { data } }
🎁 All Our Packages
- @feelinglovelynow/datetime-local: NPM ⋅ Github
- @feelinglovelynow/dgraph: NPM ⋅ Github
- @feelinglovelynow/env-write: NPM ⋅ Github
- @feelinglovelynow/get-form-entries: NPM ⋅ Github
- @feelinglovelynow/get-relative-time: NPM ⋅ Github
- @feelinglovelynow/global-style: NPM ⋅ Github
- @feelinglovelynow/jwt: NPM ⋅ Github
- @feelinglovelynow/loop-backwards: NPM ⋅ Github
- @feelinglovelynow/slug: NPM ⋅ Github
- @feelinglovelynow/svelte-catch: NPM ⋅ Github
- @feelinglovelynow/svelte-kv: NPM ⋅ Github
- @feelinglovelynow/svelte-loading-anchor: NPM ⋅ Github
- @feelinglovelynow/svelte-modal: NPM ⋅ Github
- @feelinglovelynow/svelte-turnstile: NPM ⋅ Github
- @feelinglovelynow/toast: NPM ⋅ Github