ChemPal Documentation - v1.6.0
    Preparing search index...
    • Type guard to validate if data matches the Macklin timestamp response structure. The timestamp endpoint returns the server's current Unix timestamp.

      Parameters

      • data: unknown

        The response data to validate

      Returns data is TimestampResponse

      Type predicate indicating if the data is a valid TimestampResponse

      const response = await fetch("/api/timestamp");
      const data = await response.json();
      if (isTimestampResponse(data.data)) {
      console.log("Server time:", data.data.timestamp);
      }
      export function isTimestampResponse(data: unknown): data is TimestampResponse {
      return v.safeParse(timestampResponseSchema, data).success;
      }