axios post请求传body参数
时间: 2023-10-21 13:05:35 浏览: 138
axios post请求传参模拟登录实例
在使用axios进行post请求时,可以通过将参数传递给`data`属性来传递body参数。具体示例代码如下:
```javascript
axios({
method: 'POST',
url: 'xxxxx',
data: {
key1: value1,
key2: value2
}
})
```
在这个例子中,`key1`和`key2`是需要传递的参数名,`value1`和`value2`是参数的值。这些参数会被放置在请求的body中传递给后端。需要注意的是,当`Content-Type`设置为`application/json`时,这些参数会被放到Request Payload中。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [axios请求中以params或body形式传递参数的区别](https://blog.csdn.net/weixin_46872121/article/details/125529999)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文