我有一些参数想要以表单编码的方式POST到我的服务器:
{
'userName': 'test@gmail.com',
'password': 'Password!',
'grant_type': 'password'
}
我像这样发送我的请求(目前没有参数)
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
});
我该如何在请求中包含表单编码的参数?
$.param({value: function(){return 'values'; }})
可以将函数作为参数传递。 - Ever CR