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 in Node-js by Vaani
• 7,020 points
16 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,740 points
209 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,740 points
1,643 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,740 points
812 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,740 points
361 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,740 points
1,959 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,740 points
1,996 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,008 views
0 votes
1 answer
0 votes
1 answer

Unable to start express server on AWS instance

It's not your code — you can't connect ...READ MORE

answered Oct 1, 2018 in AWS by Priyaj
• 58,080 points
2,053 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP