How do I send the fetch to the backend?
onSubmit (e) {
var random = stringGen(6);
e.preventDefault();
let details = new FormData();
details.append('demo_id', random);
details.append('description', this.state.description);
details.append('url', this.state.url);
fetch (backend+'/api/demos/create/details', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: details
})
.then(() => {
location.reload();
});
}
How the req.body
arrives in the backend
How can I make it arrive as a simple json
Something like this
{
dato : valor,
dato : valor
}