ApiPost如何自动登录获取token并设置为全局变量
直接上代码
console.log("执行全局脚本");
$.ajax({
"url":apt.variables.getPreUrl()+"/loginWithOutCode",
"method":"POST",
"async":false,
headers:{
"content-type":"application/json"
},
"data":JSON.stringify({"username": "admin","password": "admin123"}),
"success":function(response){
response = typeof response == "object" ? response : JSON.parse(response);
console.log("执行成功:");
console.log(response);
apt.globals.set("token", response.token);
}
});