[英]Pass multiple params to a POST - Axios
I'm trying to pass a team
object a league_id
integer as parameters to my post request. 我正在尝试将
team
对象的league_id
整数作为参数传递给我的帖子请求。 But I can only seem to get the team params to pass... 但是我似乎只能让团队参数通过...
Here is what I'm working with: 这是我正在使用的:
onSubmit: function () {
axios.post('/api/v1/teams', {team: {name: this.$refs.team_name.value}, league_id: this.$route.params.id}, {
headers: {
Authorization: "Bearer "+localStorage.getItem('token')
}
}).then(response => {
this.$router.push('/')
}).catch(error => {
this.$router.push('/create_team')
})
}
This is what my server receives: 这是我的服务器收到的:
%{"team" => %{"name" => "face"}}
I want it to look like this: 我希望它看起来像这样:
%{"team" => %{"name" => "face"}, "league_id" => 15}
How can I form this request with Axios? 如何与Axios一起提出此请求?
可能是因为您的this。$ route.params.id为null或未定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.