天天看點

axios發送post form請求

執行個體

隻需修改url和data即可

axios({
  url: '/user',
  method: 'post',
  data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
  },
  transformRequest: [function (data) {
  
    let ret = ''
    for (let it in data) {
      ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
    }
    return ret
  }],
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
})
           

本文來自部落格園,作者:403·Forbidden,轉載請注明原文連結:https://www.cnblogs.com/lczmx/p/12695336.html

繼續閱讀