The unwrapped response data to validate
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;
}
Validates the unwrapped
datapayload of a successful MSDS search.requeststrips 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.