In jquery, Ajax requests to send post are convenient, but in Vue projects, the introduction of jquery is no longer appropriate.
var This var data = { filter:'-_id '}$.ajax ({ URL:' http://localhost:3000/api/goods/get ') , type:' post ', data:data, dataType:' json ', success: function(res) { =res.data } )
There are two places to pay great attention to post requests in Axios:
To set the appropriate request header, generally use x-www-form-urlencoded can
Send the data to serialize, pay special attention to Ah, because the Axios default format is the request Payload.
Axios.post (' Http://localhost:3000/api/goods/get ', qs.stringify (data), { headers: { ' Content-type ': ' application/x-www-form-urlencoded; Charset=utf-8 ' } }). Then (res = = res.data = { Console.log (Err) })
wherein the QS module is a package into the Axios module,
When introducing Axios, QS can be introduced simultaneously.
Such as:
Import Axios from ' Axios ' import qs from ' QS '
The post in the Axios is particularly large in a pit.