How to perform a POST request with the parameters of the Badi and Hader?

Please help to perform post request to retrieve 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!')))
 }


Error:
Unhandled Rejection (TypeError): Failed to execute 'fetch' on 'Window': The provided value is not of type
March 19th 20 at 08:34
1 answer
March 19th 20 at 08:36
Solution
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!')));


Good, your app needs to communicate with the server via the REST API, the data is transferred in JSON format.

Sehardcore access key is not the best solution.

Find more questions by tags ReactAPI