GET请求
axios({
method: "GET",
url: "xxxxx",
params: param,
});
// 或者
axios({
method: "GET",
url: "/xxx?message=" + msg,
});
异步
// 为给定 ID 的 user 创建请求
axios
.get("/user?ID=12345")
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
// 上面的请求也可以这样做
axios
.get("/user", {
params: {
ID: 12345,
},
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});