@brandboostinggmbh/painless
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -283,3 +283,3 @@ var __defProp = Object.defineProperty; | ||
); | ||
await fetch( | ||
const result = await fetch( | ||
`${this.baseUrl}cart/add.js`, | ||
@@ -296,2 +296,14 @@ { | ||
); | ||
if (result.status >= 400) { | ||
if (result.status == 422) { | ||
const error = await result.json(); | ||
return error; | ||
} | ||
try { | ||
const error = await result.json(); | ||
return error; | ||
} catch (e) { | ||
return { status: result.status, description: result.statusText }; | ||
} | ||
} | ||
this.evt.emit("updated"); | ||
@@ -298,0 +310,0 @@ } |
type CartEvents = 'updated'; | ||
type Error = { | ||
status: number; | ||
description: string; | ||
}; | ||
export declare class Cart { | ||
@@ -15,4 +19,4 @@ private baseUrl; | ||
properties?: Record<string, string>; | ||
} | number | string>): Promise<void>; | ||
} | number | string>): Promise<Error | void>; | ||
} | ||
export {}; |
@@ -25,2 +25,4 @@ export interface ProductVariant { | ||
selling_plan_allocations: any[]; | ||
inventory_policy: "continue" | "deny"; | ||
inventory_quantity: number; | ||
} | ||
@@ -27,0 +29,0 @@ export interface AddToCartError { |
{ | ||
"name": "@brandboostinggmbh/painless", | ||
"private": false, | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
41365
1220