138
rated 0 times
[
144]
[
6]
/ answers: 1 / hits: 7409
/ 2 Years ago, tue, december 28, 2021, 12:00:00
I'm getting the error, TypeError: Cannot read properties of undefined (reading 'find')
which points to the block of code:
app.get('/Organizations', (req,res) => {
Organizations.find({}).then((organization) => {
res.send(organization);
}); })
app.js, importing mongoose schema:
const {Organizations} = require('./db/models');
Organization.model.js:
const mongoose = require('mongoose');
const OrganizationsSchema = new mongoose.Schema({
organizationName:{
type: String,
required: true,
minlength:1,
trim: true
}
})
const Organizations = mongoose.model( 'Organizations', OrganizationsSchema);
module.exports = (Organizations)
index.js:
const { Organizations } = require('./Organizations.model');
module.exports = {
Organizations
}
More From » node.js