axios で application/x-www-form-urlencoded な POST

2019/03/14   #JavaScript  #axios 
このエントリーをはてなブックマークに追加

パラメータを querystring で文字列化するのと、 headers'Content-Type': 'application/x-www-form-urlencoded' を設定するのがミソだった。

const querystring = require('querystring')

axios.post(url, querystring.stringify({
  hoge: 'a',
  fuga: 2
}), {
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
}).then(() => {
  :