mysql - 以角度读取节点表达的响应
问题描述
我正在尝试使用 MEAN(Mysql、Express、Angular、Node)制作登录表单。我在读取节点的响应并相应地显示消息时遇到问题。在调查该问题时需要一些帮助。
这些 if else 条件也无法正常工作。帮助!!!!!!!!!!!!
postmethod(post)
{
this._http.login(post).subscribe(
(resp) => {
if(resp) this.response = resp;
console.log( resp );
//this resp(in json format) is ok.....need code(from resp json) from it..Also these if else blks are not working correct. //
var ccode = this.response.code;
if(ccode = 200)
{ this.qresult = 'Login Succesfull'; }
else if (ccode = 202)
{
this.qresult = 'Email and password does not match';
}
else
{
this.qresult = 'Email does not exits';
}
this.data_enter = true;
console.log("this.response.code);
console.log("Success From Login Method");
});
}
节点功能
app.post('/login' , jsonParser , function(req, resp)
{
var username= req.body.username;
var password = req.body.password;
connection.query('SELECT * FROM users WHERE username = ?',[username], function (error, results, fields) {
if (error) {
// console.log("error ocurred",error);
resp.send({
"cod+hgee":400,
"failed":"error ocurred"
})
}else{
if(results.length >0){
console.log(results[0]);
if(results[0].Password == password){
resp.send({
code : "200",
"success":"login sucessfull"
});
}
else{
resp.send({
code:"202",
"success":"Email and password does not match"
});
}
}
else{
resp.send({
code:"204",
"success":"Email does not exits"
});
}
}
});
});
解决方案
推荐阅读
- stata - 绘制加权数据时,箱线图失去了“盒子”性质
- c# - 使用 Nuget 包进行多项目设置
- firefox - 为什么我的光标无法删除正确位置的单词?
- javascript - Node.js - 如何检查解析的 json 是否具有与类相同的结构?
- java - java stringvars 是什么意思?
- java - 使用 shell 脚本启动远程 (SSH) Java 应用程序不会返回本地提示
- powerbi - PowerBI 中详细信息值的串联
- javascript - Browserify 破解功能。错误“未捕获的 ReferenceError:未定义 foo”
- java - /register java.lang.IllegalStateException: RESTEASY003765: 响应已关闭
- django - BooleanWidget 未在 django-filter 中定义