Kumara
Kumara

Reputation: 528

send request using Fetch method

I need to send request using 'fetch' method. I need to send below data to my header

enter image description here

I need to send below data in request body

enter image description here

i am trying to do it using below code. but actually I have not proper idea to do it. can u help me.

 fetch("http://disaida.com/api/endpoint/", {
  method: "post",
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    PREPAY: ppy,
    InputParameters: int
  })
})
.then( (response) => { 
  
});

Upvotes: 0

Views: 191

Answers (1)

sonali
sonali

Reputation: 758

Your data format is incorrect. TRY Also, based on your description, you might have to add the cookie property to your header

let data = {
    PREPAY: {
     InputParameters: {
     P_USER_NAME : "[email protected]"
     }
    }
  }

fetch("http://disaida.com/api/endpoint/", {
  method: "post",
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(data)
})
.then( (response) => { 
console.log("RR"+response.json())
}).catch(err => console.log("error",err));

Upvotes: 1

Related Questions