Answer the question
In order to leave comments, you need to log in
How to execute a POST request with badi and header parameters?
Please help me complete a post request to get json
constructor(){
super();
this.state = {
assets: []
}
}
componentDidMount() {
fetch('3.xxx.xx.xxx:8080/assets', {
method: 'post',
headers: "Content-Type: application/x-www-form-urlencoded",
body: "key=ecmdecmedmjrjekrkl"
})
.then(assets => this.setState({assets}, () => console.log('Fetched!')))
}
Answer the question
In order to leave comments, you need to log in
const form = new FormData();
form.append('key', 'ecmdecmedmjrjekrkl');
fetch('/some-path', {
method: 'POST',
headers: "Content-Type: application/x-www-form-urlencoded",
body: form,
}).then(assets => this.setState({assets}, () => console.log('Fetched!')));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question