Send Post request in Node js Rest API

0 votes

FROM THE CLIENT SIDE, I CAN'T SEND A POST REQUEST!

I must use the Node js Rest API to deliver an HTTP Post request to the payment gateway. Headers and a body payload are required for a post request. I use a Rest API with Express.js and have my frontend and backend separated. Since the payment gateway requires server-to-server connection, I am unable to implement that from the client side. Basically, I have to call my backend server when a user hits the "Payment" button, and then my backend server has to make a request to the payment gateway.

The only MVC (Model View Controller) documentation available for payment gateways is not very helpful.

Consequently, the controller's logic should look like this.

exports.payment = (req, res, next) => {
   const { amount, id, currency } = req.body;

   //add headers
   //create body paloyad

   //send request to https://payment....com/api-key/transaction

   //receive response

   res.status(200).json({ status: 'success' });
}
Jun 27, 2022 in Node-js by Vaani
• 7,070 points
1,206 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Node-js

0 votes
1 answer

How is an HTTP POST request made in node.js?

Hello @kartik, A easier way if you use ...READ MORE

answered Jul 20, 2020 in Node-js by Niroj
• 82,840 points
945 views
0 votes
1 answer

How to process POST data in Node.js?

Hello @kartik, You can use the querystring module: var qs = ...READ MORE

answered Jul 9, 2020 in Node-js by Niroj
• 82,840 points
2,637 views
0 votes
1 answer

How to read environment variables in Node.js?

Hello @kartik, Yes,you can read environment variables in Node.js ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
1,631 views
0 votes
1 answer

How to write files in Node.js?

Hello @kartik, Currently there are three ways to ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
932 views
0 votes
1 answer

How to get GET (query string) variables in Express.js on Node.js?

Hello @kartik, Since you've mentioned Express.js in your ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
3,275 views
–1 vote
1 answer

How to uninstall npm modules in node js?

Hello @kartik, The command is simply: npm uninstall ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
3,212 views
0 votes
0 answers

How can i make my REST API Faster with nodejs and express?

Summarize the problem My problem: I have built ...READ MORE

Aug 19, 2022 in Node-js by Neha
• 9,020 points
811 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,946 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,470 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP