axios post application/x-www-form-urlencoded参数问题

axios.post(url, {a: 1, b:2}, {
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
  },
}).then(response => response.data)
  .then(data => {
    console.log(data);
  });

这个Form Data后台取不到数据,正常的Form Data数据不是应该是健值对的么,像下面这样:

加上qs好了:

var qs = require('qs');
axios.post('/foo', qs.stringify({ 'bar': 123 });

猜你喜欢

转载自www.cnblogs.com/wenxiangxu/p/9281091.html
今日推荐