tags: Problem solving record ajax post http vue
promise = service.delete(url, {params: params} )
export const removeGroupById = (param) => {
return ajax('/trap', `/agentGroup`, param, 'DELETE')
}
# id_arr is an array
this.removeGroupById(id_arr)



Just will
promise = service.delete(url, {params: params} )
Change to
promise = service.delete(url, {data: params} )



Back-end interface requirements -------- The position of the request parameter is written in the body! ! !

[1] GET generates one TCP data packet, and POST generates two TCP data packets.
[2] For GET requests, the browser will send the http header and data together, and the server will respond with 200 (return data);
[3] For POST, the browser first sends the header, the server responds with 100 continue, the browser then sends data, and the server responds with 200 ok (return data).
The parameters passed by the get method in http are generally query string parameters, and the requested url will be? +parameters Splicing form
Request Payload, the requested parameters are placed in the request body
Because params are added to the request string of the url, they are used for get requests.
The data is added to the request body and used for post requests.
For example, for the followinggetRequest:
axios({
method: "get",
url: "http://www.tuling123.com/openapi/api?key=20ff1803ff65429b809a310653c9daac",
params: {
info: "Xi'an Weather"
},
})
If we change params to data, obviously the request cannot be successful, becausegetThe data option does not exist in the request.
Default value of Content-type of form in html: Content-type: application/x-www-form-urlencoded
If you use an ajax request, the request payload appears in the request header to cause the parameter method to change,
Then the solution is:
headers: {‘Content-Type’:‘application/x-www-form-urlencoded’}
Or use ajax settings:
$.ajaxSetup({contentType: ‘application/x-www-form-urlencoded’});

axios.request({
method: 'post',
url: url,
params: { key1: val1},
paramsSerializer: function(params) {
// arrayFormat can format your array parameters
return qs.stringify(params, { arrayFormat: 'brackets' })
}
})
In the HTTP request, if it is a get request, the form parameters are appended to the URL in the form of name=value&name1=value1; post request: The form parameters are in the request body, and are ...
axios difference data and request params Parameters: two arrays, a string, to the backed-induced blog. When using axios, noticed configuration options include both params and data, I thought they were...
I. Introduction: The most commonly sent request in the front end is the GET request and the post request. The get request can only pass the Query parameter. The query parameters are spelled on the req...
Query String Parameters When a GET request is initiated, the parameters will be passed in the form of url string. That is, the string after the? Is its request parameter, with & as the separator. ...
When we send AJAX, we will always find the following: Query String Parameters This is an identification that occurs when the URL is behind the URL. Formdata This is a POST request, set the request hea...
Copyright statement: Please indicate the source of the author (Dugushangliang dugushangliang) for reprinting: https://blog.csdn.net/dugushangliang/article/details/90473735 Verified and usable. ...
Data and Params PARAMS is a request string addition to the URL, primarily used for GET requests: generally used to obtain data, pass parameters through the URL Data is added to the request body (for t...
If data occurs in a desired manner requestPayload submission, please put the parameter data which follows: If you want the data to the QueryString Parameters of submission, as follows: ...
Today, when I was working (Diteng WeChat applet), I found that sending a post request to the node background server could not receive the parameters from the front end. In fact, it is not completely i...
1.query string parameters 2.form data 3.request payload ...