I have some parameters that I want to POST form-encoded to my server:
{
'userName': 'test@gmail.com',
'password': 'Password!',
'grant_type': 'password'
}
I’m sending my request (currently without parameters) like this
var obj = {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
};
fetch('https://example.com/login', obj)
.then(function(res) {
// Do stuff with result
});
How can I include the form-encoded parameters in the request?