Home > Software engineering >  Edit HTTP request payload in javascript DOM
Edit HTTP request payload in javascript DOM

Time:09-14

A HTTP call is made when I click on the "place order" button in my big-commerce store. The "payment name" is whatever we selected from the radio buttons on the checkout page. As you can see in the image, I selected "instore" option from the dropdown & HTTP request is made with that selected payload.

SCREENSHOT

I want to change this payload to my own custom text. How can I achieve this? The reason for this is because I am making custom payment method & I want to use company name in the "payment name".

CodePudding user response:

use a library like axios to post your request.

axios.post('/user/12345', {
  cardid: 'xxxxx',
  payment: {
      name: "abc",
   }
})

CodePudding user response:

also you can pass an object in axios

    let paylod  ={
    cardId:"",
    paymentMessage:"",
    paymentName:"insotre"
    }
    let auth_token = "your token"
    
    const { data }= await axios({
    methode:post,
    url:"your_link"
    data:paylod
//if you passing token for authorisation
    headers: { Authorization: `Bearer ${auth_token}` },
    })
    
  • Related