var request = require('request');
var options = {
'method': 'POST',
'url': 'http://',
'headers': {
},
form: {
'username': '',
'password': ''
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
преобразование этого в ax ios запрос:
let data = qs.stringify({ 'username': '',
'password': '' })
const options = {
method: 'POST',data,
headers: { 'Content-Type': 'application/x-www-form-urlencoded'},
url: '',
};
response[0] = await Axios(options).then((res) => {
console.log("res",res)
return res.data
}
).catch((err) => {
console.log("err status", err.response.status)
return err.response.data
});
выдает ошибку, и показанные заголовки не имеют закодированный URL:
url: '',
method: 'post',
data: 'username=&password=',
headers: {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.19.2'
},
Почему контент- type: url-encoded отсутствует в заголовках и отображается только Accept: 'application / json, text / plain, / '.