I am working for a Backend application, When I am testing with Thunder Client data is not coming by id
Here is the screenshot
Error is
[nodemon] starting `node server.js`
Database Connected
I'm listening on port 4000
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'MongoClient'
| property 's' -> object with constructor 'Object'
| property 'sessionPool' -> object with constructor 'ServerSessionPool'
--- property 'client' closes the circle
at JSON.stringify (<anonymous>)
at stringify (D:servernode_modulesexpresslibresponse.js:1159:12)
at ServerResponse.json (D:servernode_modulesexpresslibresponse.js:272:14)
at getUserById (D:servercontrollerusers.js:27:32)
at Layer.handle [as handle_request] (D:servernode_modulesexpresslibrouterlayer.js:95:5)
at next (D:servernode_modulesexpresslibrouterroute.js:149:13)
at Route.dispatch (D:servernode_modulesexpresslibrouterroute.js:119:3)
at Layer.handle [as handle_request] (D:servernode_modulesexpresslibrouterlayer.js:95:5)
at D:servernode_modulesexpresslibrouterindex.js:284:15
at param (D:servernode_modulesexpresslibrouterindex.js:365:14)
controllerusers.js
const getUserById = (req, res, next) => {
const userId = req.params.userId;
try {
const user = userService.findUserByProperty('_id', userId)
if (!user) {
throw error('User not found', 404)
}
return res.status(200).json(user);
} catch (e) {
next(e)
}
};
I tested the whole with so many id & parameters and changed those id & parameters, but the problem is the same