Closed paulinal3 closed 2 years ago
Hi Paulina, are you still having this issue?
yes
Could still use help on this if/whenever anyone is available 🙏🏼
you're missing a parenthesis and curly brace before you start your .then
, your code looks like this:
db.user.findAll({
where: {
userId: res.locals.currentUser.id,
}
.then(foundUser => {
and it's trying to run .then inside the findAll, add a parenthesis before .then like this:
db.user.findAll({
where: {
userId: res.locals.currentUser.id,
}})
.then(foundUser => {
My bad, I forgot to update my code. I found that error yesterday, here's what it looks like now:
router.post('/saves/', (req, res) => {
const exerciseData = JSON.parse(JSON.stringify(req.body))
console.log('this is the exercise data to be saved', exerciseData)
db.user.findOne({
where: {id: res.locals.currentUser.id}
})
console.log('this is the userId\n', id)
.then(foundUser => {
console.log('saving exercise to this user\n', foundUser.name)
foundUser.createExercise({
name: exerciseData.name,
bodyPart: exerciseData.bodyPart,
equipment: exerciseData.equipment,
muscleTargeted: exerciseData.muscleTargeted,
exerciseDemo: exerciseData.exerciseDemo
})
.then(savedExercise => {
console.log('exercise details saved to db\n', savedExercise)
})
})
})
but now I've been getting the error id is not defined
get rid of the console log and you should be good to go
that was it! thank you!!
I'm trying to figure out how to add what the user saves to their list. This is the the error I'm not getting:
TypeError: {(intermediate value)}.then is not a function