Answer the question
In order to leave comments, you need to log in
VueJs how to send a post request with parameters?
Send request like this
this.$http.post('http://localhost:3000/store', {something: 'string'}, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}})
Answer the question
In order to leave comments, you need to log in
I don't know VueJs, but there is an alternative - the old-fashioned XMLHttpRequest or $.post. Why this sugar, which does not sweeten, but only makes you look at what has already been done many years ago. How long will there be stupid questions on the toaster "How to send a post request" of which there are already more than 680. Ridiculous.
Tell me, how is your post different from my two options? I'm guessing nothing.
Your question is not very clear. Key of another object?
If you want the value that is in the something variable to be driven in instead of the something key, then you need to create an object in the variable and then pass this variable (object) to the request.
var data = {};
var something = 'test_key';
data[something] = 'string';
this.$http.post('http://localhost:3000/store', data, ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question