0
index js.:
$.ajax({
type:'POST',
url: 'http://localhost:3000/login',
dataType: 'application/json',
data: {username: username, password: password}
})
.done(data => {
console.log(data);
});
in my Node api:
app.post('/login',async function(req,res){
email = req.body.username;
password = req.body.password;
return await db.find(email,password);
});
in the db function:
module.exports.find = async function(email,password){
search(email,password).then(a => {
return a;
});
};
function search(email,password){
return new Promise((resolve,reject) => {
table.find({where: {email: email, password:password}}).done(function(data,err){
if(data != "" && data != null)
resolve(data);
});
});
}
The function does not return the value pro data although I used async await to wait for the answer and only come back when I picked it up, someone can help?