我需要从api获取会话id,并将其作为Axios POST输入的一部分来获取用户信息。但是,虽然在代码中找不到任何错误,但我总是会收到会话过期错误。请帮帮我!
data() {
return {
customer: {
data:{
method: "customer_login",
email: "vishal@magemad.com",
password: "admin123",
session_id: ""
}
}
};登录(){
var api = 'http://159.203.179.154/sports-web/webservices/api2.php';
var admin = {
data: {
method: "admin_login",
key: "admin123",
user: "admin"
}
};
let axiosConfig = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
"Access-Control-Allow-Origin": "*",
}
};
Axios.post(api, admin, axiosConfig)
.then((res) => {
const id = res.data.data.session_id.slice(2,-2);
this.customer.data.session_id = id;
Axios.post(api, this.customer)
.then((res) => {
console.log(JSON.stringify(this.customer.data));
//console.log(res);
alert(JSON.stringify(res));
})
.catch((err) => {
console.log("AXIOS ERROR:", err);
});
//alert(JSON.stringify(this.customer));
})
.catch((err) => {
console.log("AXIOS ERROR:", err);
});发布于 2019-07-05 06:56:40
我找到了答案。结果,我不需要分割会话id。
https://stackoverflow.com/questions/56855016
复制相似问题