Multipart

Use FormData for files and named fields together. This snippet targets this site’s demo endpoint.

import { Http, bare } from "fetchzen";
const body = new FormData();
body.set("file", new File(["Hello"], "demo.txt"));
body.set("name", "Ada");
const api = Http.create(`${location.origin}/api/examples/`, {
cache: false, secure: false, preset: bare,
});
console.log(await api.post("multipart/", body));
Try this requestMultipart file + form field
Request parameters

Only Run sends a request to this site's demo API. Use synthetic data only; do not send secrets or personal files. Uploads are counted, not stored.

Ready. No request sent.

Fetch does not report upload progress. Wait for the server's receipt to confirm the file arrived.

Result

Choose Run to see the response.
Event log
No events yet.

Do not set Content-Type manually: Fetch supplies the multipart boundary. The bounded demo returns counts and discards files and fields without storage. The file limit is 1 MiB; browser Fetch does not report upload progress.

Next: raw file upload or download.