我有这个数组:
postData = [region_id: 18, net_forces: 29, region_adder: 1, my_game_action: "deploy", active_player_id: 1]
我想用axios
发布它,我似乎无法实现这一目标。我希望最终得到:
axios.post(turn_route, {
region_id: 18,
net_forces: 29,
region_adder: 1,
my_game_action: 'deploy',
active_player_id: 1
})
我试过了:
axios.post(turn_route, JSON.stringify(postData))
.then(function(response) {
axios.post(turn_route, postData)
.then(function(response) {
axios.post(turn_route, data: {postData: postData})
.then(function(response) {
axios.post(turn_route, {params: {postData}})
.then(function(response) {
我找不到一个应该是什么常见的例子。感谢
答案 0 :(得分:-2)
postData不是数组,它的对象和正确的定义是
postData = {region_id: 18, net_forces: 29, region_adder: 1, my_game_action: "deploy", active_player_id: 1}
你需要
axios.post(turn_route, postData).then(function(response) {})