-1
I am doing a project where I need to access a user ID (the database is just an obj for now). however when trying to make a destructin:
---> const {id}= req.body; <---
let found= false;
database.users.map(user=>{
if(user.id===id){
found = true;
return res.json(database.users);
}
})
my destructin ID has no value. i have a Login for the project, and when soon with the user I have an id. this user’s Obj is given as an answer after Login, and should be compared to the user.id ID for my project to work. but I am not able to use the information my Login expele.
my "login" is this, if useful:
app.post("/signin",(req,res)=>{
if(req.body.email=== database.users[0].email &&
req.body.password===database.users[0].password){
res.json(database.users[0]);
}else{
res.status(400).json("erro de login");
}
})
from now on Agradeco ;)
I liked the method, but this condition continues to give an indefinite value. the problem itself is in the proper id of (const {id}= req.body;), it is Undefined, but it should contain the id that comes from my login response. I enter the application, with email and password and login responds to the obj corresponding to this data, it is from this obj that I want the id of distructin, but I am not able to reference I think
– arthurMurray
req.body id comes from the request, from the json file you send via post...
– Hugo Moraes Bonatto