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

127
Views
How to handle retrieving amount of submits with Node Express

Problem Explanation

I have 3rd party (Stripe) form in my app that users submit. I would like to be able to count number of submits and display it on the front end.

Code Explanation

This is my route for form submit (works fine)

const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);

const stripeChargeCallback = (res) => (stripeErr, stripeRes) => {
  if (stripeErr) {
    res.status(500).send({ error: stripeErr });
  } else {
    res.status(200).send({ success: stripeRes });
  }
};

const paymentApi = (app) => {
  app.get('/payment', (req, res) => {
    res.send({
      message: 'Hello Stripe checkout server!',
      timestamp: new Date().toISOString(),
    });
  });

  app.post('/payment', (req, res) => {
    const body = {
      source: req.body.token.id,
      amount: req.body.amount,
      currency: 'dkk',
    };
    stripe.charges.create(body, stripeChargeCallback(res));
  });

  return app;
};

I am not sure if I can just add to this routing logic for counting submits or it should new route.

This is a (useless) solution on frontend I would like to replace and connect with Express: (ProgressBar is bootstrap component)

const addOneLocalStorage = JSON.parse(localStorage.getItem('sold') || 0);

const [addOne, setAddOne] = useState(addOneLocalStorage);

const handleAdd = () => {
  setAddOne(addOne + 1);
  localStorage.setItem('sold', addOne);
};

<ProgressBar animated now={addOne} min={0} max={100} />;

I tried to Google how to handle such a thing (since I am not a backend developer), but I can't find any resource, would appreciate any help here.

about 4 years ago · Juan Pablo Isaza
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!