WDI-SEA / project-4-issues

Open an issue to receive help on project 4 issues
0 stars 0 forks source link

Having an issue hitting a server route #62

Open isaac8069 opened 2 years ago

isaac8069 commented 2 years ago

What stack are you using?

(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)

MERN

What's the problem you're trying to solve?

Im trying to find all user apartments using the userId

Post any code you think might be relevant (one fenced block per file)

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

I originally was getting a 404 error. Now I am getting an undefined for req.owner. I've refactored the code a few times.

What is your best guess as to the source of the problem?

Not being able to grab the user

What things have you already tried to solve the problem?

Multiple refactoring of code has taken place. i even looked at change password to see how the user was found

timmshinbone commented 2 years ago

what you're looking for is req.user to compare with apartment.owner, req.user comes from the requiretoken middleware

isaac8069 commented 2 years ago

I attempted both but my console.log is bringing back undefined. I thought I could just search apartments using the Owner: 'User' ref in Apartment model. That seemed like the logical thing to do. When that didn't work I tried finding the user with User.findById, but that didn't work either.