问题描述
更新的问题
我正在尝试从表单 URL 编码的服务器获取令牌,但是每当我这样做时,我都会收到 400 错误的请求错误。
async componentDidMount() {
var details = {
'client_id': 'client','username': 'username','password': 'TestPassword!01'
};
var formBody = [];
for (var property in details) {
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(details[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");
console.log(formBody)
await axios({
method: "post",url: "my api",headers:{
'Content-Type': 'application/x-www-form-urlencoded'
},body: formBody
}).then(res => console.log(res))
.catch(err => console.log(err));
}
如果我控制台日志'formbody'我得到正确的字符串,但仍然是同样的问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)