0

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) => { 
  
});
2

1 Answer 1

1

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));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.