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

    Function isMacklinMsdsSearchResponse

    • Validates the unwrapped data payload of a successful MSDS search. request strips the { code, message, data } envelope, so a success yields { url } while error responses yield [], which fails the { url } shape — a positive result therefore means an SDS URL is present.

      Parameters

      • data: unknown

        The unwrapped response data to validate

      Returns data is MacklinMsdsSearchResponse

      Type predicate indicating the data is a successful MacklinMsdsSearchResponse

      const data = await this.request("/api/msds/search", { params: { keyword } });
      if (isMacklinMsdsSearchResponse(data)) {
      console.log(data.url);
      }
      export function isMacklinMsdsSearchResponse(data: unknown): data is MacklinMsdsSearchResponse {
      return v.safeParse(macklinMsdsSearchResponseSchema, data).success;
      }