ChemPal Documentation - v1.6.0
    Preparing search index...
    • Type guard validating that a value matches the MySimpleStore search/list response envelope: an object with a products array whose items each carry the minimal id/slug/name/relative_url fields the supplier reads.

      Parameters

      • response: unknown

        The value to validate (typically a parsed JSON response)

      Returns response is MySimpleStoreSearchResponse

      Type predicate indicating whether response is a valid search response

      const data = await this.httpGetJson({ host: this.apiHost, path: "/api/v2/products" });
      if (isValidSearchResponse(data)) {
      for (const product of data.products) console.log(product.name);
      }
      export function isValidSearchResponse(response: unknown): response is MySimpleStoreSearchResponse {
      return v.safeParse(mySimpleStoreSearchResponseSchema, response).success;
      }