admin管理员组文章数量:1415673
I'm sending the request this way
this.$http.post('http://localhost:3000/store', {something: 'string'}, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}})
And if you look through the browser, the parameters look like this
enter image description here
in image i show object which look like ({"something":"string"}:)
Note that my object is the key of another object (If you use json.stringfy (), my object will still be the key of another object) Why did it happen and how to make a normal object?
I'm sending the request this way
this.$http.post('http://localhost:3000/store', {something: 'string'}, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}})
And if you look through the browser, the parameters look like this
enter image description here
in image i show object which look like ({"something":"string"}:)
Note that my object is the key of another object (If you use json.stringfy (), my object will still be the key of another object) Why did it happen and how to make a normal object?
Share Improve this question asked Jun 11, 2017 at 12:14 Nimble StalkerNimble Stalker 3735 silver badges15 bronze badges2 Answers
Reset to default 2I think the best way to do this is create the object first.
var something = "key";
var obj = {};
obj[something] = 'string';
this.$http.post('http://localhost:3000/store', obj, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}})
<script>
var mixin = {
var url = 'http://localhost/vue/serv.php';
this.$http.get(url, {params: {action: 'buscar', userid:'2'}, headers: {'X-Custom': '...'}}).then(response => {
this.usuarios = response.body;
console.log(response);
}, response => {
console.log(error);
});
}
}
new Vue({
el: '#resultado',
mixins: [mixin],
data:{
titulo: "Vue lmideias",
usuarios: []
}
});
</script>
本文标签: javascriptVueJs how to send a post request with parametersStack Overflow
版权声明:本文标题:javascript - VueJs how to send a post request with parameters? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745235700a2649026.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论