Send form data as application/x-www-form-urlencoded using URLSearchParams.
Code
Utilitiesconst params = new URLSearchParams();
params.append('username', 'john');
params.append('password', 'secret123');
params.append('remember', 'true');
const response = await fetch('https://httpbin.org/post', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: params
});
await response.json();Browser·fetch() may be limited by CORS
When to Use
- HTML form submissions
- OAuth token requests
- Legacy APIs expecting form data
- Simple key-value data without files
More JavaScript Snippets
Add Query Parameter
Add or update a query parameter in a URL string.
Bearer Token Authentication
Make an authenticated HTTP request using Bearer token for JWT or OAuth.
Check Cloudflare Cache Status
Check if a resource is served from Cloudflare's cache by inspecting the CF-Cache-Status header.
CORS Cross-Origin Request
Make a cross-origin HTTP request with CORS headers inspection.
Delayed Response (Test Timeouts)
Request a delayed response to test timeout handling with AbortController.
Download Binary File
Download an image or binary file and convert it to a blob or base64.