The parsed AJAX response to test
True when value carries a data object
const parsed = await this.httpPostJson({ path, body });
if (isScienceLabAttributeResponse(parsed)) {
const price = parsed.data?.price?.without_tax?.value;
}
export function isScienceLabAttributeResponse(
value: unknown,
): value is ScienceLabAttributeResponse {
return isPopulatedObject(value) && isPopulatedObject(value.data);
}
Type guard for the ScienceLab (BigCommerce) product-attributes AJAX response. Narrows an unknown parsed value to ScienceLabAttributeResponse by requiring that it be an object carrying a
dataobject. The variant price is read fromdata.price.without_tax.value, which callers still null-check.