To send a URL as data in a JavaScript fetch() request, put it in the request body and set Content-Type to text/uri-list—but only if the receiving endpoint expects that format. The URL in fetch()‘s first argument is the request destination; it is not the URL being submitted.
Send a URL as a URI-list body
A text/uri-list payload is plain text containing one URI per line. For a single URL, the request can look like this:
const response = await fetch("https://api.example.com/submit", {
method: "POST",
headers: { "Content-Type": "text/uri-list" },
body: "https://example.com/resourcern",
});
This is a format example, not a tested request to a real API: api.example.com is illustrative. Use the method, endpoint, and payload format documented by your API. Some endpoints may expect JSON or another content type instead.
Keep the destination separate from the submitted URL
These parts of the request do different jobs:
fetch("https://api.example.com/submit", ...)selects the endpoint that receives the request.bodycarries the submitted URL as data.Content-Typedescribes the format of that body.
If you want to retrieve a page rather than submit its address to an API, use that page’s URL as the fetch() destination. For example, fetch("https://example.com/resource") requests that resource; it does not send the address as a text/uri-list body.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems#1 Best Overall
Format one or more URIs correctly
RFC 2483 defines text/uri-list as a simple format for lists of URLs and URNs intended for automatic processing. Put each URI on its own line and terminate lines with CRLF (rn). Lines beginning with # are comments, so do not begin a URI with # to represent its fragment.
For multiple URLs, join the entries with CRLF and include a final CRLF:
Rank #2
const uriList = [
"https://example.com/first",
"https://example.com/second",
].join("rn") + "rn";
const response = await fetch("https://api.example.com/submit", {
method: "POST", // Use the method documented by the endpoint.
headers: { "Content-Type": "text/uri-list" },
body: uriList,
});
RFC 2483 specifies the format and security considerations in RFC 2483. MDN explains how the URL argument, request body, and headers work in its Fetch API guide.
Check the endpoint contract before sending
The media type alone does not determine whether a request will succeed. Verify the API documentation for its required HTTP method, accepted content types, authentication, CORS behavior, and rules for validating submitted URIs. The example above cannot establish those endpoint-specific details.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteValidate URIs before automatic processing
A submitted URI list is untrusted input. If a server or client will automatically retrieve the listed destinations, validate the allowed schemes and destinations first. RFC 2483 warns that dereferencing entries can expose confidential locations or trigger consequential actions; see its security considerations.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Do not confuse this with a javascript: URL
JavaScript code can call fetch() and set an HTTP header through the request options. A javascript: URI is instead a navigation target that runs code; it is neither a content type nor a way to set request headers. MDN describes JavaScript URLs and the structure of URI schemes.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




