Answer the question
In order to leave comments, you need to log in
Mongodb why FindOne works but Find doesn't?
here is the code
if (req.url === '/login' && req.method === 'POST') {
console.log('login');
res.setHeader('content-type','application/json; charset=utf-8');
res.setHeader('Access-Control-Allow-Origin','*');
let data = '';
req.on('data',(dataSumbol) => {
data+=dataSumbol.toString();
})
req.on('end',async () => {
data = JSON.parse(data);
let infoBD = await db.find({email:data.email,password:data.password});
console.log('data',infoBD);
if (!infoBD) {
res.end(JSON.stringify({
resultCode:1,
textErorr:'ivalid login or password',
}));
return
} else {
res.end(JSON.stringify(infoBD));
}
})
return
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question