I'm setting up a simple API using nestjs with typeorm and mongodb. However when I make a simple http request I get the following error
[Nest] 8852 - 09/28/2021, 6:06:03 PM [ExceptionsHandler] Cannot read property 'prototype' of undefined +4874934ms TypeError: Cannot read property 'prototype' of undefined at FindCursor.cursor.toArray (C:\Users\admin\Documents\projects\shoplist\api\node_modules\typeorm\entity-manager\MongoEntityManager.js:669:37) at MongoEntityManager.<anonymous> (C:\Users\admin\Documents\projects\shoplist\api\node_modules\typeorm\entity-manager\MongoEntityManager.js:60:54) at step (C:\Users\admin\Documents\projects\shoplist\api\node_modules\tslib\tslib.js:143:27) at Object.next (C:\Users\admin\Documents\projects\shoplist\api\node_modules\tslib\tslib.js:124:57) at fulfilled (C:\Users\admin\Documents\projects\shoplist\api\node_modules\tslib\tslib.js:114:62) at processTicksAndRejections (internal/process/task_queues.js:95:5)
offices.controller.ts
@Get('/list')
findAll() {
return this.officesService.findAll();
}
offices.service.ts
async findAll() {
try {
const offices = await this.officesRepository.find();
return { success: true, message: 'Office successfully retrieved!', data: offices }
} catch(e) {
throw new InternalServerErrorException({ success: false, error: e.message })
}
}
I honestly don't know why it gives me error 500 with that message. Any idea what's happening?