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

    Function isEpagesSearchResponse

    • Type guard for the ePages catalog search response (POST /api/v2/search). Verifies the products array (each with an id, name, and links) and the totalNumberOfProducts count used to drive pagination.

      Parameters

      • response: unknown

        The value to validate

      Returns response is EpagesSearchResponse

      Type predicate indicating whether response is an EpagesSearchResponse

      const json = await httpPostJson({ path: "/api/v2/search", body: { query: "" } });
      if (isEpagesSearchResponse(json)) {
      console.log(`${json.totalNumberOfProducts} products in catalog`);
      }
      export function isEpagesSearchResponse(response: unknown): response is EpagesSearchResponse {
      return v.safeParse(epagesSearchResponseSchema, response).success;
      }