Every time I try to execute this code, an error pops up stating that err is undefined
Below is the code snippet causing the issue:
app.post('/tinder/cards', (req, res) => {
const dbCard = req.body;
Cards.create(dbCard, (err, data) => {
if (err) {
res.status(500).send(err);
} else {
res.status(201).send(data);
}
});
app.get('/tinder/cards', (req, res) => {
Cards.find(err, data => {
if (err) {
res.status(500).send(err);
} else {
res.status(200).send(data);
}
});
Here is how I defined the MongoDB schema:
import mongoose from 'mongoose';
const cardSchema = mongoose.Schema({
name: String,
imgUrl: String,
});
export default mongoose.model('cards', cardSchema);
Any assistance in resolving this issue would be greatly appreciated. Thank you!