【发布时间】:2023-03-15 19:20:01
【问题描述】:
我正在尝试向我没有太多控制权的服务器发送发布请求。我唯一知道的是,如果我在 Postman 中发布以下数据,我可以获得正确的响应
x-www-form-urlencoded radio button checked
Entered the following 2 array data:
product_id_list[] pid1234
product_id_list[] pid1235
Header - Content-Type: application/x-www-form-urlencoded
Method: Post
但是当我尝试通过 axios 进行操作时,似乎无法通过正确的参数数据。我试过了
axios.post('https://test.com/api/get_product,
querystring.stringify({
'product_id_list': ['pid1234', 'pid1235']
}))
.
.
.
axios.post('https://test.com/api/get_product,
querystring.stringify({
'product_id_list[]': 'pid1234',
'product_id_list[]': 'pid1235'
}))
.
.
.
有人知道如何在 axios 中翻译这种类型的数组数据吗?
【问题讨论】:
标签: javascript reactjs http axios