#StackBounty: #node.js #json #mongoose TypeError: Converting circular structure to JSON node js

Bounty: 50

when i try to get my api via postman i have this error

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'NativeTopology'
    |     property 's' -> object with constructor 'Object'
    |     property 'sessionPool' -> object with constructor 'ServerSessionPool'
    --- property 'topology' closes the circle

i use mongoose and express

const express = require('express')
const Rent = require('../model/rent')
var stringify = require('json-stringify-safe');

route = express()

route.use(express.json());

route.get('/rent', (req,res) => {
    const rents = Rent.find();
    res.send(JSON.stringify(rents))
})

module.exports = route

if i delete JSON.stringify i have the same problem
Thank you in advance


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.