Skip to content

Commit

Permalink
Use FormData to serialize the form
Browse files Browse the repository at this point in the history
  • Loading branch information
bespoyasov committed Jan 21, 2022
1 parent 1631356 commit 62d16cb
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ function App() {
e.preventDefault();
setStatus("loading");

const couponElement = e.target
.closest("form")
.querySelector('[name="coupon"]');
const couponValue = couponElement.value;
const coupon = String(couponValue);
const { coupon } = Object.fromEntries(new FormData(e.target));

try {
if (!cart.products.length) throw new Error("The cart is empty.");
Expand Down

0 comments on commit 62d16cb

Please sign in to comment.