Simply formData parsing

This commit is contained in:
Jorge Vargas 2025-03-10 22:50:21 -06:00
parent 0e6e08beb2
commit 12063db819
2 changed files with 15 additions and 5 deletions

View file

@ -2,3 +2,13 @@ import slugify from 'slugify'
export const Status = (status: number, statusText?: string) => new Response(null, { status, statusText })
export const slug = (text: string) => slugify(text, { lower: true, strict: true })
export function formToObject(formData: FormData) {
const object: Record<string, any> = {}
for (const entry of formData.entries()) {
const [key, value] = entry
object[key] = value
}
return object
}