axios get请求传递数组参数
var ttt = [{column: "username", type: "EQ", values: "ts"},]var test = {pageNum: 1,pageSize: 30,params: JSON.stringify(ttt)}// $.ajax({//type: "GET",//url: "http://localhost:8099/api/sy.
·
var ttt = [
{column: "username", type: "EQ", values: "ts"},
]
var test = {
pageNum: 1,
pageSize: 30,
params: JSON.stringify(ttt)
}
// $.ajax({
// type: "GET",
// url: "http://localhost:8099/api/sysUser",
// beforeSend: function(xhr) {
// xhr.setRequestHeader("X-Token", "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiYXVkIjoibWlkZG9sIiwiaXNzIjoidXNlcl9jZW50ZXIiLCJleHAiOjE2MTI1MTUwOTYsInVzZXJJZCI6MSwiaWF0IjoxNjEyNTExNDk2fQ.T-AtWBNU5OnGViFOD2LGoCSoQNo3kwxYXb2JFBL8peU");
// },
// contentType: "application/json;charset=utf-8",
// data: test,
// dataType: "json",
// success: function(response, status, request){
// console.log("111111111111111111")
// console.log(response);
// console.log(status);
// console.log(request.getAllResponseHeaders());
// }
// });
axios.defaults.baseURL = 'http://localhost:8099/api';
axios.defaults.headers.common['X-Token'] = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiYXVkIjoibWlkZG9sIiwiaXNzIjoidXNlcl9jZW50ZXIiLCJleHAiOjE2MTI1MTg4MzYsInVzZXJJZCI6MSwiaWF0IjoxNjEyNTE1MjM2fQ.2PI5F9Ad-dTUBnQqxjidEybhJik9T1Czs6VCWHyZ9dU";
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8';
axios.get("/sysUser", {
params: test,
paramsSerializer: function(params) {
return Qs.stringify(params, {arrayFormat: 'repeat'})
}
})
.then(function(response){
console.log(response)
}).catch(function(error){
console.log("报错啦")
console.log(error)
})
效果:
更多推荐
已为社区贡献1条内容
所有评论(0)