@robinpath/formdata
v0.3.0
Published
Multipart form data builder and file upload handling
Readme
@robinpath/formdata
Multipart form data builder, file uploads, URL encoding/decoding, and form submission
Why use this module?
The formdata module lets you:
- Create a FormData object from key-value pairs
- Add a text field to a FormData
- Add a file to a FormData
- Submit a FormData to a URL
- URL-encode an object as application/x-www-form-urlencoded
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
robinpath add @robinpath/formdataQuick Start
No credentials needed — start using it right away:
formdata.addField $form "name" "Alice"Available Functions
| Function | Description |
|----------|-------------|
| formdata.create | Create a FormData object from key-value pairs |
| formdata.addField | Add a text field to a FormData |
| formdata.addFile | Add a file to a FormData |
| formdata.submit | Submit a FormData to a URL |
| formdata.encode | URL-encode an object as application/x-www-form-urlencoded |
| formdata.decode | Decode a URL-encoded form body |
| formdata.uploadFile | Upload a file to a URL as multipart form |
| formdata.parseMultipart | Parse a multipart form body |
Examples
Add a text field to a FormData
formdata.addField $form "name" "Alice"Add a file to a FormData
formdata.addFile $form "avatar" "./photo.jpg"Submit a FormData to a URL
formdata.submit "https://api.example.com/upload" $formIntegration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/formdata";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
formdata.addField $form "name" "Alice"
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/form— Declarative form builder for defining form fields inline@robinpath/json— JSON module for complementary functionality
License
MIT
