Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
Retrieve data from HTML form to server file

I am working on the Stripe payment API and I have a form to collect data that is written in HTML and would like to retrieve the collected data to another javascript file (server.js). I have tried changing the ${AMOUNT} to req.body.amount but seems that is not the case. Is it actually possible to retrieve the data via the form method? Or it is only be done in the fetch method?

HTML:

<form action="/create-checkout-session" method="POST" id="create-checkout-session">
  <div className="description">
    <span>Price:</span> 
    <input type="number" className="field" id="amount" name="amount" min="500"/>
    <button type="submit" id="checkout">
      Checkout
    </button>
  </div>
</form>

Javascript (server.js):

app.post('/create-checkout-session', async (req, res) => {
const session = await stripe.checkout.sessions.create({
line_items: [
  {
    price_data: {
      currency: 'hkd',
      product_data: {
        name: "Test",
      },
      unit_amount: ${AMOUNT},
    },
    quantity: 1,
  },
],
mode: 'payment',
success_url: `${YOUR_DOMAIN}?success=true`,
cancel_url: `${YOUR_DOMAIN}?canceled=true`,});
res.redirect(303, session.url);
});
app.listen(4242, () => console.log('Running on port 4242'));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have solved this by adding express.urlencoded in the server.js, which looks like this:

app.use(express.urlencoded({ extended: true }));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!