Skip to content

Commit

Permalink
catch error on cart
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinfirman committed Apr 22, 2024
1 parent 891b7c2 commit a82c887
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/b2b/app/routes/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ export async function action({request, context}: ActionFunctionArgs) {
throw new Error(`${action} cart action is not defined`);
}

/***********************************************/
/********** EXAMPLE UPDATE STARTS ************/
if (!result.cart) {
return json({
cart: null,
errors: result.userErrors,
});
}
/********** EXAMPLE UPDATE END ************/
/***********************************************/

const cartId = result.cart.id;
const headers = cart.setCartId(result.cart.id);
const {cart: cartResult, errors} = result;
Expand Down

0 comments on commit a82c887

Please sign in to comment.