ChemPal Documentation - v1.7.0
    Preparing search index...

    Module helpers/request

    Functions - Helpers

    getRequestHash

    Generates a unique hash for a given Request object based on its method, URL path, search parameters, and body. This hash can be used to identify and cache requests. This is used to store the mocked response body at a location with a unique filename (based on the hash). This is necessary because the only other way to differentiate between request really is to store the file in a location that contains the hostname, request method, request path and then some way to differentiate between the request body and parameters. But even trying that causes issues. Trying to dynamically import the file ./responses/${reqUrl.hostname}/${reqUrl.path}/${searchQuery}.json throws the exception:

    getCachableResponse

    Creates a cacheable response object from a Request and Response pair. This function serializes the response content based on its content type and generates a hash for the request to be used as a cache key.

    urlencode

    Encodes a string to be used in a URL.

    createDOM

    Converts an HTML string to a DOM Document object.

    fetchDecorator → fetchDecorator

    Re-exported from ./fetch so callers can reach the request helpers through a single entry point.

    generateRequestHash → generateRequestHash

    Re-exported from ./fetch so callers can reach the request helpers through a single entry point.

    generateSimpleHash → generateSimpleHash

    Re-exported from ./fetch so callers can reach the request helpers through a single entry point.