What is the difference between post api call and form submission with post method?

后端 未结 2 1369
庸人自扰
庸人自扰 2021-01-29 04:38

I want to call payment gateway, for that payment gateway is called using form submission with the method as post, Can I call the same gateway using post API call fr

2条回答
  •  萌比男神i
    2021-01-29 04:43

    Form data is usually sent like

    address=Stackoverflow&poster=Ashkay
    

    Whereas a normal post in JSON format will be like

    {
       "address": "stackoverflow",
       "poster": "Ashkay"
    }
    

    You can mimic a form POST request in NodeJS, e.g:

    const request = require("request");
    
    request({
      uri: "http://www.test.com/payment/gateway.php",
      method: "POST",
      form: {
        address: "Stackoverflow",
        name: "Ashkay"
      }
    }, function(error, response, body) {
      console.log(body);
    });
    
    

提交回复
热议问题