interface CommercetoolsHooks {
    onAfterResponse?: (response: CommercetoolsRequestResponse) => void;
    onBeforeRequest?: (
        requestConfig: CommercetoolsRequest,
    ) =>
        | Omit<
            CommercetoolsRequest,
            "timeoutMs"
            | "retry"
            | "aggregateTimeoutMs"
            | "abortController",
        >
        | Promise<
            Omit<
                CommercetoolsRequest,
                "timeoutMs"
                | "retry"
                | "aggregateTimeoutMs"
                | "abortController",
            >,
        >;
}

Hierarchy (View Summary)

Properties

onAfterResponse?: (response: CommercetoolsRequestResponse) => void

If passed in, will be called once a request has been made and the response received (or error thrown).

onBeforeRequest?: (
    requestConfig: CommercetoolsRequest,
) =>
    | Omit<
        CommercetoolsRequest,
        "timeoutMs"
        | "retry"
        | "aggregateTimeoutMs"
        | "abortController",
    >
    | Promise<
        Omit<
            CommercetoolsRequest,
            "timeoutMs"
            | "retry"
            | "aggregateTimeoutMs"
            | "abortController",
        >,
    >

If passed in, will be called before sending a request to commercetools. The {@see requestConfig} parameter can be manipulated if you wish to modify/add headers or any other request data.