Hi everyone, I am currently trying to implement a tutorial (https://www.youtube.com/watch?v=rMijvDtNYlQ&t=935s) where u can register a user through the moralis auth, in next with the mongodb, about eveything works just fine, but when I try to update the bio nothing happens.
I am using the same code used in the video, and I think that the part that is causing me issues is in the api/updateBio.js
file.
this bit to be more precise.
import connectDB from "../../lib/connectDB"
import Users from "../../lib/models/userSchema"
export default async function updateBio(req, res) {
const { profileId, bio } = req.body
console.log(req.body)
console.log(profileId, bio)
await connectDB()
try {
await Users.findOneAndUpdate({ profileId: profileId }, { bio: bio })
res.status(200).json({ bio })
} catch (error) {
res.status(400).json({ error })
console.error(error)
}
}
I tried to log the profileId
and the bio
in the api/updateBio file and it returns undefined. I also logged the req.body as you can see below.
So it seems that it is because we are trying to destructure an array ? Did anyone face the same issue ?