问题描述
我有RESTFUL后端烧瓶服务,其中有两个登录功能,如果使用signed_in,我只是在使用flaks会话,我的代码如下
@app.route('/api/log_in/')
def log_in():
try:
#..fetching sucessful credential from DB
session['username'] = email
session['fname'] = entity['Fname']
session['lname'] = entity['Lname']
return jsonify({'res':True})
@app.route('/api/is_logged_in/')
def is_logged_in():
if 'username' in session:
response=jsonify({"res":True})
else:
response = jsonify({"res": False})
当我第一次做长时间然后在浏览器中测试is_login时,我得到了正确的期望,is_logged_in总是给我正确的真实值,
但是我把它带到reactjs并通过axion调用来调用此API,或者当我登录时,后遗症is_logged_in总是给我错误
我在reactjs中的axios调用如下:
axios.get('http://127.0.0.1:9000/api/is_logged_in/')
.then(res =>{
if (res.status!=200) {
throw new Error('Network response was not ok');}
return res;})
.then(res=>{
const value=res.data.res;
set_is_logged_in(value);
console.log(value);
})
当我在浏览器上模拟但在我的reactjs应用程序上模拟时,这不是为什么它可以正常工作吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)