ChemPare Documentation - v0.0.0
    Preparing search index...

    Function generateRequestHash

    • 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.

      Parameters

      • input: URL | RequestInfo

        The request URL or Request object

      • Optionaloptions: RequestInit

        Optional request configuration

      Returns Promise<string>

      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);