The request URL or Request object
Optional
options: RequestInitOptional request configuration
A promise that resolves to a unique hash string
// With URL string
const hash1 = await generateRequestHash("https://api.example.com/data", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "test" })
});
// With Request object
const request = new Request("https://api.example.com/data", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "test" })
});
const hash2 = await generateRequestHash(request);
Generates a unique hash for a request based on its URL, method, headers, and body. This hash can be used to identify and track unique requests.