使用'content-type'发布数据发布数据:'application / x-www-form-urlencoded'和'key':'key'

问题描述 投票:0回答:1

我想使用标题内容类型将数据发布到服务器:'application / xww-form-urlencode'但由于内容类型更改为application / json而失败

var headers= {
           'content-type': 'application/x-www-form-urlencoded', 
            'x-access-key': 'key'
}    
var data = {
      'twins' : twins
}    
axios.post('url', data, { headers: headers })
          .then((response) => {
            console.log(response)
          })
          .catch((error) => {
            console.log(error)
          })

随着邮差我成功添加了条目By posting data with postman I set the headers like in image shown below] and the body like this

reactjs typescript axios
1个回答
0
投票

在你的标题中将content-type更改为

'Content-Type': 'application/x-www-form-urlencoded'

如果这不起作用,那么我觉得你可能正在使用拦截器。这可能会覆盖您的配置。

© www.soinside.com 2019 - 2024. All rights reserved.