I'm trying to make a POST in react, and I have an error that says {"error_description":"Missing grant type"}
in postman works fine, what am I doing wrong?
Thanks!
Here is my code
class App extends Component {
constructor() {
super()
this.state = {
info : null
}
}
componentDidMount() {
var payload = {
client_id: 'my_site',
grant_type: 'my_credentials',
client_secret: 'xxx',
}
var data = new FormData();
data.append("json",JSON.stringify(payload));
fetch('/myendpoint', {
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: data
})
})
.then(function(res){
return res.json();
})
.then(function(data){
alert( JSON.stringify( data ) )
})